Skip to content

Commit

Permalink
Merge pull request #8 from jeffmccune/feature/master/third_party_dhcp…
Browse files Browse the repository at this point in the history
…d_conf

Make the dhcp module more reusable
  • Loading branch information
Branan Purvine-Riley committed Jun 8, 2012
2 parents f468ba0 + 1caa8ac commit 228da18
Showing 1 changed file with 56 additions and 13 deletions.
69 changes: 56 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
$dnsdomain,
$nameservers,
$ntpservers,
$interfaces = undef,
$interface = 'NOTSET',
$dnsupdatekey = undef,
$pxeserver = undef,
$pxefilename = undef,
$logfacility = 'daemon',
$default_lease_time = 3600,
$max_lease_time = 86400,
$failover = ''
$dhcp_conf_header = 'INTERNAL_TEMPLATE',
$dhcp_conf_ddns = 'INTERNAL_TEMPLATE',
$dhcp_conf_pxe = 'INTERNAL_TEMPLATE',
$dhcp_conf_extra = 'INTERNAL_TEMPLATE',
$dhcp_conf_fragments = {},
$interfaces = undef,
$interface = 'NOTSET',
$dnsupdatekey = undef,
$pxeserver = undef,
$pxefilename = undef,
$logfacility = 'daemon',
$default_lease_time = 3600,
$max_lease_time = 86400,
$failover = ''
) {

include dhcp::params
Expand All @@ -30,6 +35,29 @@
$dhcp_interfaces = $interfaces
}

# JJM Decide where to pull the fragment content from. Either this module, or
# from the end user. This makes the module much more re-usable by 3rd
# parties without modifying the module itself.
#
# NOTE: These templates should be evaluated after all other local variables
# have been set.
$dhcp_conf_header_real = $dhcp_conf_header ? {
INTERNAL_TEMPLATE => template('dhcp/dhcpd.conf-header.erb'),
default => $dhcp_conf_header,
}
$dhcp_conf_ddns_real = $dhcp_conf_ddns ? {
INTERNAL_TEMPLATE => template('dhcp/dhcpd.conf.ddns.erb'),
default => $dhcp_conf_ddns,
}
$dhcp_conf_pxe_real = $dhcp_conf_pxe ? {
INTERNAL_TEMPLATE => template('dhcp/dhcpd.conf.pxe.erb'),
default => $dhcp_conf_pxe,
}
$dhcp_conf_extra_real = $dhcp_conf_extra ? {
INTERNAL_TEMPLATE => template('dhcp/dhcpd.conf-extra.erb'),
default => $dhcp_conf_extra,
}

package { $packagename:
ensure => installed,
provider => $operatingsystem ? {
Expand Down Expand Up @@ -60,23 +88,38 @@
concat { "${dhcp_dir}/dhcpd.conf": }
concat::fragment { 'dhcp-conf-header':
target => "${dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.conf-header.erb'),
content => $dhcp_conf_header_real,
order => 01,
}
concat::fragment { 'dhcp-conf-ddns':
target => "${dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.conf.ddns.erb'),
content => $dhcp_conf_ddns_real,
order => 10,
}
concat::fragment { 'dhcp-conf-pxe':
target => "${dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.conf.pxe.erb'),
content => $dhcp_conf_pxe_real,
order => 20,
}
concat::fragment { 'dhcp-conf-extra':
target => "${dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.conf-extra.erb'),
content => $dhcp_conf_extra_real,
order => 99,
}

# Any additional dhcpd.conf fragments the user passed in as a hash for
# create_resources. This allows the end user almost total control over the
# DHCP server without modifying this module at all.

# JJM This is commented out because the create_resources in PE does not
# support the third option.
# $fragment_defaults = {
# content => "# Managed by Puppet\n",
# target => "${dhcp_dir}/dhcpd.conf",
# order => 80,
# }
create_resources('concat::fragment', $dhcp_conf_fragments)

# dhcpd.pool
concat { "${dhcp_dir}/dhcpd.pools": }
concat::fragment { 'dhcp-pools-header':
Expand Down

0 comments on commit 228da18

Please sign in to comment.