diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/host.pp | 36 | ||||
-rw-r--r-- | manifests/params.pp | 31 | ||||
-rw-r--r-- | manifests/server/base.pp | 50 | ||||
-rw-r--r-- | manifests/server/debian.pp | 26 | ||||
-rw-r--r-- | manifests/shared-network.pp | 31 | ||||
-rw-r--r-- | manifests/subnet.pp | 73 |
6 files changed, 131 insertions, 116 deletions
diff --git a/manifests/host.pp b/manifests/host.pp index d946ae9..969ecc4 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -1,20 +1,28 @@ -/* +# = 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 ( + $mac, + $subnet, + $ensure = present, + $fixed_address = false, + $options = false +) { -= 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 - concat::fragment {"dhcp.host.$name": + + concat::fragment {"dhcp.host.${name}": ensure => $ensure, target => "${dhcp::params::config_dir}/hosts.d/${subnet}.conf", - content => template("dhcp/host.conf.erb"), - notify => Service["dhcpd"], + content => template('dhcp/host.conf.erb'), + notify => Service['dhcpd'], } + } diff --git a/manifests/params.pp b/manifests/params.pp index 4a8eaa1..d14746c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,22 +1,27 @@ -/* +# = Class: dhcp::params +# +# Do NOT include this class - it won't do anything. +# Set variables for names and paths +# +class dhcp::params { -= Class: dhcp::params -Do NOT include this class - it won't do anything. -Set variables for names and paths + case $::operatingsystem { -*/ -class dhcp::params { - case $operatingsystem { Debian: { - $config_dir = $lsbdistcodename? { - lenny => "/etc/dhcp3", - squeeze => "/etc/dhcp", + $config_dir = $::lsbdistcodename? { + lenny => '/etc/dhcp3', + squeeze => '/etc/dhcp', } - $srv_dhcpd = $lsbdistcodename? { - lenny => "dhcp3-server", - squeeze => "isc-dhcp-server", + $srv_dhcpd = $::lsbdistcodename? { + lenny => 'dhcp3-server', + squeeze => 'isc-dhcp-server', } } + + default: { + fail "${name} is not available for ${operatingsystem}/${lsbdistcodename}" + } + } } diff --git a/manifests/server/base.pp b/manifests/server/base.pp index 53cbd70..4e7d645 100644 --- a/manifests/server/base.pp +++ b/manifests/server/base.pp @@ -1,26 +1,24 @@ -/* - -= 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 +# +# 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 include concat::setup - - package {"dhcp-server": + + package {'dhcp-server': ensure => present, name => $dhcp::params::srv_dhcpd, } - service {"dhcpd": - name => $dhcp::params::srv_dhcpd, + service {'dhcpd': ensure => running, + name => $dhcp::params::srv_dhcpd, enable => true, - require => Package["dhcp-server"], + require => Package['dhcp-server'], } concat {"${dhcp::params::config_dir}/dhcpd.conf": @@ -29,39 +27,39 @@ class dhcp::server::base { mode => '0644', } - concat::fragment {"00.dhcp.server.base": + concat::fragment {'00.dhcp.server.base': ensure => present, target => "${dhcp::params::config_dir}/dhcpd.conf", - require => Package["dhcp-server"], - notify => Service["dhcpd"], + require => Package['dhcp-server'], + notify => Service['dhcpd'], } file {"${dhcp::params::config_dir}/dhcpd.conf.d": - ensure => directory, - mode => 0700, + ensure => directory, + mode => '0700', recurse => true, purge => true, force => true, - source => "puppet:///modules/dhcp/empty" + source => 'puppet:///modules/dhcp/empty' } file {"${dhcp::params::config_dir}/subnets": - ensure => directory, - require => Package["dhcp-server"], - notify => Service["dhcpd"], + ensure => directory, recurse => true, purge => true, force => true, - source => "puppet:///modules/dhcp/empty" + source => 'puppet:///modules/dhcp/empty', + require => Package['dhcp-server'], + notify => Service['dhcpd'], } file {"${dhcp::params::config_dir}/hosts.d": - ensure => directory, - require => Package["dhcp-server"], + ensure => directory, recurse => true, purge => true, force => true, - source => "puppet:///modules/dhcp/empty" + source => 'puppet:///modules/dhcp/empty', + require => Package['dhcp-server'], } } diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp index 3cc7508..5d23bbe 100644 --- a/manifests/server/debian.pp +++ b/manifests/server/debian.pp @@ -1,21 +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 +# +# 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 { - Concat::Fragment["00.dhcp.server.base"] { + Concat::Fragment['00.dhcp.server.base'] { content => template('dhcp/dhcpd.conf.debian.erb'), } - Service["dhcpd"] { - pattern => $lsbdistcodename ? { - squeeze => "/usr/sbin/dhcpd", - lenny => "/usr/sbin/dhcpd3", + Service['dhcpd'] { + pattern => $::lsbdistcodename ? { + squeeze => '/usr/sbin/dhcpd', + lenny => '/usr/sbin/dhcpd3', } } + } diff --git a/manifests/shared-network.pp b/manifests/shared-network.pp index 2154d37..9a02a5b 100644 --- a/manifests/shared-network.pp +++ b/manifests/shared-network.pp @@ -1,22 +1,25 @@ -/* +# == 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 = [] +) { -== 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 + concat::fragment {"shared-${name}": ensure => $ensure, target => "${dhcp::params::config_dir}/dhcpd.conf", - content => template("dhcp/shared-network.erb"), + content => template('dhcp/shared-network.erb'), require => Dhcp::Subnet[$subnets], } + } diff --git a/manifests/subnet.pp b/manifests/subnet.pp index 15afd53..18ffdc5 100644 --- a/manifests/subnet.pp +++ b/manifests/subnet.pp @@ -1,40 +1,41 @@ -/* - -= 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;'], - } -} -*/ +# = 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, + $ensure=present, $netmask=false, $routers=false, $subnet_mask=false, $domain_name=false, $other_opts=false, - $is_shared=false) { + $is_shared=false +) { + include dhcp::params concat {"${dhcp::params::config_dir}/hosts.d/${name}.conf": @@ -44,13 +45,13 @@ define dhcp::subnet( } file {"${dhcp::params::config_dir}/subnets/${name}.conf": - ensure => $ensure, - owner => root, - group => root, - content => template("dhcp/subnet.conf.erb"), - notify => Service["dhcpd"], + ensure => $ensure, + owner => root, + group => root, + content => template('dhcp/subnet.conf.erb'), + notify => Service['dhcpd'], } - + if ! $is_shared { concat::fragment {"dhcp.${name}": ensure => $ensure, |