Puppet Class: pxe_install::dhcp
- Defined in:
- manifests/dhcp.pp
Summary
Setup DHCP serverOverview
Configure DHCP server and add static DHCP entries, create pools
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'manifests/dhcp.pp', line 12
class pxe_install::dhcp (
Hash $dhcp
) {
if pxe_install::hash_key($dhcp, 'default_filename') {
$pxefilename = $dhcp['default_filename']
} elsif $pxe_install::defaults['pxefile'] != '' {
$pxefilename = $pxe_install::defaults['pxefile']
} else {
# Default
$pxefilename = 'pxelinux.0'
}
if pxe_install::hash_key($dhcp, 'ipxe_bootstrap') and pxe_install::hash_key($dhcp, 'ipxe_filename') {
$ipxe_config = {
ipxe_bootstrap => $dhcp['ipxe_bootstrap'],
ipxe_filename => $dhcp['ipxe_filename'],
}
} else {
$ipxe_config = {}
}
if pxe_install::hash_key($dhcp, 'globaloptions') {
$_globaloptions = $dhcp['globaloptions']
} else {
$_globaloptions = []
}
$dhcp_global_options = {
service_ensure => running,
interfaces => $dhcp['interfaces'],
nameservers => $dhcp['dns_servers'],
ntpservers => $dhcp['ntp_servers'],
pxeserver => $dhcp['next_server'],
dnsdomain => $dhcp['domain_names'],
pxefilename => $pxefilename,
omapi_port => $dhcp['omapiport'],
ddns_update_style => $dhcp['ddns_update_style'],
max_lease_time => $dhcp['max_lease_time'],
default_lease_time => $dhcp['default_lease_time'],
logfacility => $dhcp['logfacility'],
option_code150_label => $dhcp['option_code_50_label'],
option_code150_value => $dhcp['option_code150_value'],
globaloptions => $_globaloptions,
}
$_dhcp_global_options = merge($dhcp_global_options, $ipxe_config)
class { 'dhcp':
* => $_dhcp_global_options,
}
# loop over subnets
if pxe_install::hash_key($dhcp, 'pools') {
$dhcp['pools'].each |$pool_name, $pool_data| {
dhcp::pool { $pool_name:
* => $pool_data,
}
}
}
# loop over dhcp entried for dynamic ips
if pxe_install::hash_key($dhcp, 'hosts') {
$dhcp['hosts'].each |$host_name, $host_data| {
dhcp::host { $host_name:
* => $host_data,
comment => "dynamic ip entry for ${host_name}",
}
}
}
}
|