diff options
author | Cédric Jeanneret <cedric.jeanneret@camptocamp.com> | 2010-11-04 14:02:31 +0100 |
---|---|---|
committer | Cédric Jeanneret <cedric.jeanneret@camptocamp.com> | 2010-11-04 14:02:31 +0100 |
commit | 68b0642c21a598b6f5aecfedd38cc1584737fbec (patch) | |
tree | fdbedfe6246b9bb467fe125097ccaf36abf4c892 /manifests | |
download | puppet-dhcp-68b0642c21a598b6f5aecfedd38cc1584737fbec.tar.gz puppet-dhcp-68b0642c21a598b6f5aecfedd38cc1584737fbec.tar.bz2 |
New module: dhcp
Install and manage a dhcp server with puppet.
Please read manifests/classes/dhcp.pp for more informations about usage.
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/classes/dhcp-base.pp | 51 | ||||
-rw-r--r-- | manifests/classes/dhcp-debian.pp | 24 | ||||
-rw-r--r-- | manifests/classes/dhcp-variables.pp | 22 | ||||
-rw-r--r-- | manifests/classes/dhcp.pp | 43 | ||||
-rw-r--r-- | manifests/definitions/dhcp-host.pp | 10 | ||||
-rw-r--r-- | manifests/definitions/dhcp-subnet.pp | 33 | ||||
-rw-r--r-- | manifests/init.pp | 2 |
7 files changed, 185 insertions, 0 deletions
diff --git a/manifests/classes/dhcp-base.pp b/manifests/classes/dhcp-base.pp new file mode 100644 index 0000000..4e1497e --- /dev/null +++ b/manifests/classes/dhcp-base.pp @@ -0,0 +1,51 @@ +/* + += Class dhcp::base +Do NOT include this class - it won't work at all. +Set variables for package name and so on. +This class should be inherited in dhcp::$operatingsystem. + +*/ +class dhcp::base { + include dhcp::variables + package {"dhcp-server": + ensure => present, + name => $dhcp::variables::srv_dhcpd, + } + + service {"dhcpd": + name => $dhcp::variables::srv_dhcpd, + ensure => running, + enable => true, + require => Package["dhcp-server"], + } + + common::concatfilepart {"00-base": + file => "${dhcp::variables::config_dir}/dhcpd.conf", + ensure => present, + require => Package["dhcp-server"], + notify => Service["dhcpd"], + } + + file {"subnet-config-dir": + path => "${dhcp::variables::config_dir}/subnets", + ensure => directory, + require => Package["dhcp-server"], + notify => Service["dhcpd"], + recurse => true, + purge => true, + force => true, + source => "puppet:///dhcp/empty" + } + + file {"dhcp-config-dir": + path => "${dhcp::variables::config_dir}/hosts.d", + ensure => directory, + require => Package["dhcp-server"], + recurse => true, + purge => true, + force => true, + source => "puppet:///dhcp/empty" + } + +} diff --git a/manifests/classes/dhcp-debian.pp b/manifests/classes/dhcp-debian.pp new file mode 100644 index 0000000..1d35cbc --- /dev/null +++ b/manifests/classes/dhcp-debian.pp @@ -0,0 +1,24 @@ +/* + += Class: dhcp::debian +Installs a dhcp server on debian system. + +This class should not be included as is, please include "dhcp" instead. + +*/ +class dhcp::debian inherits dhcp::base { + + Common::Concatfilepart["00-base"] { + content => $lsbdistcodename ? { + squeeze => template('dhcp/dhcpd.conf.squeeze.erb'), + lenny => template('dhcp/dhcpd.conf.lenny.erb'), + } + } + + Service["dhcpd"] { + pattern => $lsbdistcodename ? { + squeeze => "/usr/sbin/dhcpd", + lenny => "/usr/sbin/dhcpd3", + } + } +} diff --git a/manifests/classes/dhcp-variables.pp b/manifests/classes/dhcp-variables.pp new file mode 100644 index 0000000..e189ae6 --- /dev/null +++ b/manifests/classes/dhcp-variables.pp @@ -0,0 +1,22 @@ +/* + += Class: dhcp::variables +Do NOT include this class - it won't do anything. +Set variables for names and paths + +*/ +class dhcp::variables { + case $operatingsystem { + Debian: { + $config_dir = $lsbdistcodename? { + lenny => "/etc/dhcp3", + squeeze => "/etc/dhcp", + } + + $srv_dhcpd = $lsbdistcodename? { + lenny => "dhcp3-server", + squeeze => "isc-dhcp-server", + } + } + } +} diff --git a/manifests/classes/dhcp.pp b/manifests/classes/dhcp.pp new file mode 100644 index 0000000..9ae7b9f --- /dev/null +++ b/manifests/classes/dhcp.pp @@ -0,0 +1,43 @@ +/* + += Class: dhcp +Simple OS wrapper. Include this to install a dhcp server on your host. + +Requires: + module "common": git://github.com/camptocamp/puppet-common.git + +Required arguments: + *$dhcpd_domain_name*: domain-name option + *$dhcpd_dns_servers*: domain-name-servers option + +facultative argument: + *$dhcpd_ddns_update*: ddns-update-style option + *$dhcpd_ddns_authoritative*: set it if you want that your DHCP server is authoritative + +Example: +node "dhcp.toto.ltd" { + $dhcpd_domain_name = 'toto.ltd' + $dhcpd_dns_servers = '192.168.21.1' + include dhcp + + dhcp::subnet {"192.168.20.0": + ensure => present, + bcast => "192.168.20.255", + dns => "192.168.21.1, 10.26.22.1", + other_opt => ['filename "pxelinux.0";', 'next-server 192.168.10.1;'], + inc => true, + } + + dhcp::host {"titi-eth0": + ensure => present, + mac => "0e:18:fa:fe:d9:00", + subnet => "192.168.20.0", + fixed_address => "192.168.10.52", + } +} +*/ +class dhcp { + case $operatingsystem { + Debian: { include dhcp::debian } + } +} diff --git a/manifests/definitions/dhcp-host.pp b/manifests/definitions/dhcp-host.pp new file mode 100644 index 0000000..747fa7c --- /dev/null +++ b/manifests/definitions/dhcp-host.pp @@ -0,0 +1,10 @@ +define dhcp::host($ensure=present,$mac,$subnet,$fixed_address=false) { + include dhcp::variables + common::concatfilepart {$name: + ensure => $ensure, + notify => Service["dhcpd"], + file => "${dhcp::variables::config_dir}/hosts.d/${subnet}.conf", + require => Dhcp::Subnet[$subnet], + content => template("dhcp/host.conf.erb"), + } +} diff --git a/manifests/definitions/dhcp-subnet.pp b/manifests/definitions/dhcp-subnet.pp new file mode 100644 index 0000000..46c55ae --- /dev/null +++ b/manifests/definitions/dhcp-subnet.pp @@ -0,0 +1,33 @@ +define dhcp::subnet( + $ensure=present, + $bcast, + $dns, + $netmask=false, + $domain_name=false, + $inc=false, + $routeurs=false, + $netbios_dns=false, + $subnet_mask=false, + $other_opt=false, + $deny=false) { + include dhcp::variables + + if $inc { + $to_inc = "${dhcp::variables::config_dir}/hosts.d/${name}.conf" + } + + file {"${dhcp::variables::config_dir}/subnets/${name}.conf": + ensure => $ensure, + owner => root, + group => root, + content => template("dhcp/subnet.conf.erb"), + notify => Service["dhcpd"], + } + + common::concatfilepart {"${name}": + file => "${dhcp::variables::config_dir}/dhcpd.conf", + ensure => $ensure, + content => "include \"${dhcp::variables::config_dir}/subnets/${name}.conf\";\n", + } + +} diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..6cc1969 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,2 @@ +import "classes/*.pp" +import "definitions/*.pp" |