diff options
author | Raphaël Pinson <raphael.pinson@camptocamp.com> | 2013-04-12 10:38:14 +0200 |
---|---|---|
committer | Raphaël Pinson <raphael.pinson@camptocamp.com> | 2013-04-12 10:38:14 +0200 |
commit | f4e7bdf477586e34e47a972172c15809ac92fe3c (patch) | |
tree | 98a5610e9d0b65b39f0705c0745f12f381d13a6b /manifests | |
parent | 0689631b833d5683bdef5885de5893450f4928ca (diff) | |
download | puppet-dhcp-f4e7bdf477586e34e47a972172c15809ac92fe3c.tar.gz puppet-dhcp-f4e7bdf477586e34e47a972172c15809ac92fe3c.tar.bz2 |
Improve template host.conf.erb with validations and add spec for dhcp::hosts
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/hosts.pp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/manifests/hosts.pp b/manifests/hosts.pp index 426d661..f8e5faf 100644 --- a/manifests/hosts.pp +++ b/manifests/hosts.pp @@ -1,4 +1,4 @@ -# = Definition: dhcp::hosts +# Definition: dhcp::hosts # # Creates a dhcp configuration for given hosts # @@ -38,15 +38,27 @@ define dhcp::hosts ( $hash_data, $subnet, - $global_options = false, - $template = 'dhcp/host.conf.erb', + $ensure = present, + $global_options = [], + $template = "${module_name}/host.conf.erb", ) { include ::dhcp::params - concat::fragment {"dhcp.host.${name}": - target => "${dhcp::params::config_dir}/hosts.d/${subnet}.conf", - content => template($template), - notify => Service['dhcpd'], + validate_string($ensure) + validate_re($ensure, ['present', 'absent'], + "\$ensure must be either 'present' or 'absent', got '${ensure}'") + validate_hash($hash_data) + validate_string($subnet) + validate_re($subnet, '^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$') + validate_array($global_options) + validate_string($template) + + if ($ensure == 'present') { + concat::fragment {"dhcp.host.${name}": + target => "${dhcp::params::config_dir}/hosts.d/${subnet}.conf", + content => template($template), + notify => Service['dhcpd'], + } } } |