From 5f4a22d6775fc091124c95bbb0b891bf95e6043c Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Tue, 15 Nov 2011 13:17:30 +0100 Subject: file renaming to be compliant with recommended module structure. --- manifests/classes/dhcp-params.pp | 22 -------- manifests/classes/dhcp-server-base.pp | 58 --------------------- manifests/classes/dhcp-server-debian.pp | 21 -------- manifests/classes/dhcp-server.pp | 37 -------------- manifests/definitions/dhcp-host.pp | 20 -------- manifests/definitions/dhcp-shared-network.pp | 22 -------- manifests/definitions/dhcp-subnet.pp | 76 ---------------------------- manifests/host.pp | 20 ++++++++ manifests/init.pp | 2 - manifests/params.pp | 22 ++++++++ manifests/server.pp | 37 ++++++++++++++ manifests/server/base.pp | 58 +++++++++++++++++++++ manifests/server/debian.pp | 21 ++++++++ manifests/shared-network.pp | 22 ++++++++ manifests/subnet.pp | 76 ++++++++++++++++++++++++++++ 15 files changed, 256 insertions(+), 258 deletions(-) delete mode 100644 manifests/classes/dhcp-params.pp delete mode 100644 manifests/classes/dhcp-server-base.pp delete mode 100644 manifests/classes/dhcp-server-debian.pp delete mode 100644 manifests/classes/dhcp-server.pp delete mode 100644 manifests/definitions/dhcp-host.pp delete mode 100644 manifests/definitions/dhcp-shared-network.pp delete mode 100644 manifests/definitions/dhcp-subnet.pp create mode 100644 manifests/host.pp delete mode 100644 manifests/init.pp create mode 100644 manifests/params.pp create mode 100644 manifests/server.pp create mode 100644 manifests/server/base.pp create mode 100644 manifests/server/debian.pp create mode 100644 manifests/shared-network.pp create mode 100644 manifests/subnet.pp (limited to 'manifests') diff --git a/manifests/classes/dhcp-params.pp b/manifests/classes/dhcp-params.pp deleted file mode 100644 index 4a8eaa1..0000000 --- a/manifests/classes/dhcp-params.pp +++ /dev/null @@ -1,22 +0,0 @@ -/* - -= Class: dhcp::params -Do NOT include this class - it won't do anything. -Set variables for names and paths - -*/ -class dhcp::params { - 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-server-base.pp b/manifests/classes/dhcp-server-base.pp deleted file mode 100644 index 1725b36..0000000 --- a/manifests/classes/dhcp-server-base.pp +++ /dev/null @@ -1,58 +0,0 @@ -/* - -= Class dhcp::server::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::server::$operatingsystem. - -*/ -class dhcp::server::base { - include dhcp::params - package {"dhcp-server": - ensure => present, - name => $dhcp::params::srv_dhcpd, - } - - service {"dhcpd": - name => $dhcp::params::srv_dhcpd, - ensure => running, - enable => true, - require => Package["dhcp-server"], - } - - common::concatfilepart {"00.dhcp.server.base": - file => "${dhcp::params::config_dir}/dhcpd.conf", - ensure => present, - require => Package["dhcp-server"], - notify => Service["dhcpd"], - } - - file {"${dhcp::params::config_dir}/dhcpd.conf.d": - ensure => directory, - mode => 0700, - recurse => true, - purge => true, - force => true, - source => "puppet:///modules/dhcp/empty" - } - - file {"${dhcp::params::config_dir}/subnets": - ensure => directory, - require => Package["dhcp-server"], - notify => Service["dhcpd"], - recurse => true, - purge => true, - force => true, - source => "puppet:///modules/dhcp/empty" - } - - file {"${dhcp::params::config_dir}/hosts.d": - ensure => directory, - require => Package["dhcp-server"], - recurse => true, - purge => true, - force => true, - source => "puppet:///modules/dhcp/empty" - } - -} diff --git a/manifests/classes/dhcp-server-debian.pp b/manifests/classes/dhcp-server-debian.pp deleted file mode 100644 index 9762384..0000000 --- a/manifests/classes/dhcp-server-debian.pp +++ /dev/null @@ -1,21 +0,0 @@ -/* - -= Class: dhcp::server::debian -Installs a dhcp server on debian system. - -This class should not be included as is, please include "dhcp::server" instead. - -*/ -class dhcp::server::debian inherits dhcp::server::base { - - Common::Concatfilepart["00.dhcp.server.base"] { - content => template('dhcp/dhcpd.conf.debian.erb'), - } - - Service["dhcpd"] { - pattern => $lsbdistcodename ? { - squeeze => "/usr/sbin/dhcpd", - lenny => "/usr/sbin/dhcpd3", - } - } -} diff --git a/manifests/classes/dhcp-server.pp b/manifests/classes/dhcp-server.pp deleted file mode 100644 index 7d56854..0000000 --- a/manifests/classes/dhcp-server.pp +++ /dev/null @@ -1,37 +0,0 @@ -/* - -= Class: dhcp::server -Simple OS wrapper. Include this to install a dhcp server on your host. - -Requires: - module "common": git://github.com/camptocamp/puppet-common.git - -facultative argument: - *$dhcpd_ddns_update* : ddns-update-style option (default to none) - *$dhcpd_authoritative* : set it if you want that your DHCP server is authoritative (default to no) - *$dhcpd_opts* : any other DHCPD valid options - -Example: -node "dhcp.toto.ltd" { - $dhcpd_opts = ['domain-name "toto.ltd"', "domain-name-servers 192.168.21.1"] - include dhcp::server - - dhcp::subnet {"10.27.20.0": - ensure => present, - broadcast => "10.27.20.255", - other_opts => ['filename "pxelinux.0";', 'next-server 10.27.10.1;'], - } - - dhcp::host {"titi-eth0": - ensure => present, - mac => "0e:18:fa:fe:d9:00", - subnet => "10.27.20.0", - fixed_address => "10.27.10.52", - } -} -*/ -class dhcp::server { - case $operatingsystem { - Debian: { include dhcp::server::debian } - } -} diff --git a/manifests/definitions/dhcp-host.pp b/manifests/definitions/dhcp-host.pp deleted file mode 100644 index 160df63..0000000 --- a/manifests/definitions/dhcp-host.pp +++ /dev/null @@ -1,20 +0,0 @@ -/* - -= Definition: dhcp::host -Create dhcp configuration for a host - -Arguments: - *$mac*: host MAC address (mandatory) - *$subnet*: subnet in which we want to add this host - *$fixed_address*: host fixed address (if not set, takes $name) - -*/ -define dhcp::host($ensure=present,$mac,$subnet,$fixed_address=false, $options=false) { - include dhcp::params - common::concatfilepart {"dhcp.host.$name": - ensure => $ensure, - notify => Service["dhcpd"], - file => "${dhcp::params::config_dir}/hosts.d/${subnet}.conf", - content => template("dhcp/host.conf.erb"), - } -} diff --git a/manifests/definitions/dhcp-shared-network.pp b/manifests/definitions/dhcp-shared-network.pp deleted file mode 100644 index 9e1e779..0000000 --- a/manifests/definitions/dhcp-shared-network.pp +++ /dev/null @@ -1,22 +0,0 @@ -/* - -== Definition: dhcp::shared-network -Creates a shared-network - -Arguments: - *$subnets* : subnet list to be included in the shared-network - -Warnings: -- subnets must exists -- subnets must have $is_shared set to true (default is false) - -*/ -define dhcp::shared-network($ensure=present, $subnets=[]) { - include dhcp::params - common::concatfilepart {"shared-${name}": - ensure => $ensure, - file => "${dhcp::params::config_dir}/dhcpd.conf", - content => template("dhcp/shared-network.erb"), - require => Dhcp::Subnet[$subnets], - } -} diff --git a/manifests/definitions/dhcp-subnet.pp b/manifests/definitions/dhcp-subnet.pp deleted file mode 100644 index c0f865b..0000000 --- a/manifests/definitions/dhcp-subnet.pp +++ /dev/null @@ -1,76 +0,0 @@ -/* - -= Definition: dhcp::subnet -Creates a subnet - -Arguments: - *$broadcast* : subnet broadcast (mandatory) - *$netmask* : subnet netmask (if not set, takes eth0 netmask) - *$routers* : subnet routers (array) (if not set, takes eth0 IP) - *$subnet_mask* : netmask sent to dhcp guests (if not set, takes $netmask, or netmask_eth0) - *$domain_name* : subnet domain name (if not set, takes server domain) - *$other_opts* : any other DHCPD option, as an array - *$is_shared* : whether it's part of a shared network or not. Default: false - -Example: - -node "dhcp.domain.ltd" { - $dhcpd_domain_name = 'domain.ltd' - $dhcpd_dns_servers = '10.27.21.1, 10.26.21.1' - include dhcp - - dhcp::subnet {"10.27.20.0": - ensure => present, - broadcast => "10.27.20.255", - other_opts => ['filename "pxelinux.0";', 'next-server 10.27.10.1;'], - } -} -*/ -define dhcp::subnet( - $ensure=present, - $broadcast, - $netmask=false, - $routers=false, - $subnet_mask=false, - $domain_name=false, - $other_opts=false, - $is_shared=false) { - include dhcp::params - - $to_include = "${dhcp::params::config_dir}/hosts.d/${name}.conf" - - file {"${dhcp::params::config_dir}/subnets/${name}.conf": - ensure => $ensure, - owner => root, - group => root, - content => template("dhcp/subnet.conf.erb"), - notify => Service["dhcpd"], - } - - if ! $is_shared { - common::concatfilepart {"dhcp.${name}": - file => "${dhcp::params::config_dir}/dhcpd.conf", - ensure => $ensure, - content => "include \"${dhcp::params::config_dir}/subnets/${name}.conf\";\n", - } - } else { - common::concatfilepart {"dhcp.${name}": - file => "${dhcp::params::config_dir}/dhcpd.conf", - ensure => absent, - content => "include \"${dhcp::params::config_dir}/subnets/${name}.conf\";\n", - } - - } - - common::concatfilepart {"subnet.${name}.hosts": - file => "${dhcp::params::config_dir}/dhcpd.conf", - ensure => $ensure, - content => "include \"${dhcp::params::config_dir}/hosts.d/${name}.conf\";\n", - } - - common::concatfilepart {"00.dhcp.${name}.base": - file => $to_include, - ensure => $ensure, - content => "# File managed by puppet\n", - } -} diff --git a/manifests/host.pp b/manifests/host.pp new file mode 100644 index 0000000..160df63 --- /dev/null +++ b/manifests/host.pp @@ -0,0 +1,20 @@ +/* + += Definition: dhcp::host +Create dhcp configuration for a host + +Arguments: + *$mac*: host MAC address (mandatory) + *$subnet*: subnet in which we want to add this host + *$fixed_address*: host fixed address (if not set, takes $name) + +*/ +define dhcp::host($ensure=present,$mac,$subnet,$fixed_address=false, $options=false) { + include dhcp::params + common::concatfilepart {"dhcp.host.$name": + ensure => $ensure, + notify => Service["dhcpd"], + file => "${dhcp::params::config_dir}/hosts.d/${subnet}.conf", + content => template("dhcp/host.conf.erb"), + } +} diff --git a/manifests/init.pp b/manifests/init.pp deleted file mode 100644 index 6cc1969..0000000 --- a/manifests/init.pp +++ /dev/null @@ -1,2 +0,0 @@ -import "classes/*.pp" -import "definitions/*.pp" diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..4a8eaa1 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,22 @@ +/* + += Class: dhcp::params +Do NOT include this class - it won't do anything. +Set variables for names and paths + +*/ +class dhcp::params { + 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/server.pp b/manifests/server.pp new file mode 100644 index 0000000..7d56854 --- /dev/null +++ b/manifests/server.pp @@ -0,0 +1,37 @@ +/* + += Class: dhcp::server +Simple OS wrapper. Include this to install a dhcp server on your host. + +Requires: + module "common": git://github.com/camptocamp/puppet-common.git + +facultative argument: + *$dhcpd_ddns_update* : ddns-update-style option (default to none) + *$dhcpd_authoritative* : set it if you want that your DHCP server is authoritative (default to no) + *$dhcpd_opts* : any other DHCPD valid options + +Example: +node "dhcp.toto.ltd" { + $dhcpd_opts = ['domain-name "toto.ltd"', "domain-name-servers 192.168.21.1"] + include dhcp::server + + dhcp::subnet {"10.27.20.0": + ensure => present, + broadcast => "10.27.20.255", + other_opts => ['filename "pxelinux.0";', 'next-server 10.27.10.1;'], + } + + dhcp::host {"titi-eth0": + ensure => present, + mac => "0e:18:fa:fe:d9:00", + subnet => "10.27.20.0", + fixed_address => "10.27.10.52", + } +} +*/ +class dhcp::server { + case $operatingsystem { + Debian: { include dhcp::server::debian } + } +} diff --git a/manifests/server/base.pp b/manifests/server/base.pp new file mode 100644 index 0000000..1725b36 --- /dev/null +++ b/manifests/server/base.pp @@ -0,0 +1,58 @@ +/* + += Class dhcp::server::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::server::$operatingsystem. + +*/ +class dhcp::server::base { + include dhcp::params + package {"dhcp-server": + ensure => present, + name => $dhcp::params::srv_dhcpd, + } + + service {"dhcpd": + name => $dhcp::params::srv_dhcpd, + ensure => running, + enable => true, + require => Package["dhcp-server"], + } + + common::concatfilepart {"00.dhcp.server.base": + file => "${dhcp::params::config_dir}/dhcpd.conf", + ensure => present, + require => Package["dhcp-server"], + notify => Service["dhcpd"], + } + + file {"${dhcp::params::config_dir}/dhcpd.conf.d": + ensure => directory, + mode => 0700, + recurse => true, + purge => true, + force => true, + source => "puppet:///modules/dhcp/empty" + } + + file {"${dhcp::params::config_dir}/subnets": + ensure => directory, + require => Package["dhcp-server"], + notify => Service["dhcpd"], + recurse => true, + purge => true, + force => true, + source => "puppet:///modules/dhcp/empty" + } + + file {"${dhcp::params::config_dir}/hosts.d": + ensure => directory, + require => Package["dhcp-server"], + recurse => true, + purge => true, + force => true, + source => "puppet:///modules/dhcp/empty" + } + +} diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp new file mode 100644 index 0000000..9762384 --- /dev/null +++ b/manifests/server/debian.pp @@ -0,0 +1,21 @@ +/* + += Class: dhcp::server::debian +Installs a dhcp server on debian system. + +This class should not be included as is, please include "dhcp::server" instead. + +*/ +class dhcp::server::debian inherits dhcp::server::base { + + Common::Concatfilepart["00.dhcp.server.base"] { + content => template('dhcp/dhcpd.conf.debian.erb'), + } + + Service["dhcpd"] { + pattern => $lsbdistcodename ? { + squeeze => "/usr/sbin/dhcpd", + lenny => "/usr/sbin/dhcpd3", + } + } +} diff --git a/manifests/shared-network.pp b/manifests/shared-network.pp new file mode 100644 index 0000000..9e1e779 --- /dev/null +++ b/manifests/shared-network.pp @@ -0,0 +1,22 @@ +/* + +== Definition: dhcp::shared-network +Creates a shared-network + +Arguments: + *$subnets* : subnet list to be included in the shared-network + +Warnings: +- subnets must exists +- subnets must have $is_shared set to true (default is false) + +*/ +define dhcp::shared-network($ensure=present, $subnets=[]) { + include dhcp::params + common::concatfilepart {"shared-${name}": + ensure => $ensure, + file => "${dhcp::params::config_dir}/dhcpd.conf", + content => template("dhcp/shared-network.erb"), + require => Dhcp::Subnet[$subnets], + } +} diff --git a/manifests/subnet.pp b/manifests/subnet.pp new file mode 100644 index 0000000..c0f865b --- /dev/null +++ b/manifests/subnet.pp @@ -0,0 +1,76 @@ +/* + += Definition: dhcp::subnet +Creates a subnet + +Arguments: + *$broadcast* : subnet broadcast (mandatory) + *$netmask* : subnet netmask (if not set, takes eth0 netmask) + *$routers* : subnet routers (array) (if not set, takes eth0 IP) + *$subnet_mask* : netmask sent to dhcp guests (if not set, takes $netmask, or netmask_eth0) + *$domain_name* : subnet domain name (if not set, takes server domain) + *$other_opts* : any other DHCPD option, as an array + *$is_shared* : whether it's part of a shared network or not. Default: false + +Example: + +node "dhcp.domain.ltd" { + $dhcpd_domain_name = 'domain.ltd' + $dhcpd_dns_servers = '10.27.21.1, 10.26.21.1' + include dhcp + + dhcp::subnet {"10.27.20.0": + ensure => present, + broadcast => "10.27.20.255", + other_opts => ['filename "pxelinux.0";', 'next-server 10.27.10.1;'], + } +} +*/ +define dhcp::subnet( + $ensure=present, + $broadcast, + $netmask=false, + $routers=false, + $subnet_mask=false, + $domain_name=false, + $other_opts=false, + $is_shared=false) { + include dhcp::params + + $to_include = "${dhcp::params::config_dir}/hosts.d/${name}.conf" + + file {"${dhcp::params::config_dir}/subnets/${name}.conf": + ensure => $ensure, + owner => root, + group => root, + content => template("dhcp/subnet.conf.erb"), + notify => Service["dhcpd"], + } + + if ! $is_shared { + common::concatfilepart {"dhcp.${name}": + file => "${dhcp::params::config_dir}/dhcpd.conf", + ensure => $ensure, + content => "include \"${dhcp::params::config_dir}/subnets/${name}.conf\";\n", + } + } else { + common::concatfilepart {"dhcp.${name}": + file => "${dhcp::params::config_dir}/dhcpd.conf", + ensure => absent, + content => "include \"${dhcp::params::config_dir}/subnets/${name}.conf\";\n", + } + + } + + common::concatfilepart {"subnet.${name}.hosts": + file => "${dhcp::params::config_dir}/dhcpd.conf", + ensure => $ensure, + content => "include \"${dhcp::params::config_dir}/hosts.d/${name}.conf\";\n", + } + + common::concatfilepart {"00.dhcp.${name}.base": + file => $to_include, + ensure => $ensure, + content => "# File managed by puppet\n", + } +} -- cgit v1.2.3