-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathproxydhcp.pp
84 lines (72 loc) · 3.02 KB
/
proxydhcp.pp
1
2
3
4
5
6
7
8
9
10
11
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
82
83
84
# Configure the DHCP component
class foreman_proxy::proxydhcp {
# puppet fact names are converted from ethX.X and ethX:X to ethX_X
# so for alias and vlan interfaces we have to modify the name accordingly
$interface_fact_name = regsubst($foreman_proxy::dhcp_interface, '[.:]', '_')
$ip = pick_default($::foreman_proxy::dhcp_pxeserver, fact("ipaddress_${interface_fact_name}"))
unless ($ip =~ Stdlib::Compat::Ipv4) {
fail("Could not get the ip address from fact ipaddress_${interface_fact_name}")
}
$net = pick_default($::foreman_proxy::dhcp_network, fact("network_${interface_fact_name}"))
unless ($net =~ Stdlib::Compat::Ipv4) {
fail("Could not get the network address from fact network_${interface_fact_name}")
}
$mask = pick_default($::foreman_proxy::dhcp_netmask, fact("netmask_${interface_fact_name}"))
unless ($mask =~ Stdlib::Compat::Ipv4) {
fail("Could not get the network mask from fact netmask_${interface_fact_name}")
}
if $foreman_proxy::dhcp_nameservers == 'default' {
$nameservers = [$ip]
} else {
$nameservers = split($foreman_proxy::dhcp_nameservers,',')
}
if $foreman_proxy::dhcp_node_type =~ /^(primary|secondary)$/ {
$failover = 'dhcp-failover'
} else {
$failover = undef
}
class { '::dhcp':
dnsdomain => $foreman_proxy::dhcp_option_domain,
nameservers => $nameservers,
interfaces => [$foreman_proxy::dhcp_interface] + $foreman_proxy::dhcp_additional_interfaces,
pxeserver => $ip,
pxefilename => $foreman_proxy::dhcp_pxefilename,
omapi_name => $foreman_proxy::dhcp_key_name,
omapi_key => $foreman_proxy::dhcp_key_secret,
}
::dhcp::pool{ $::domain:
network => $net,
mask => $mask,
range => $foreman_proxy::dhcp_range,
gateway => $foreman_proxy::dhcp_gateway,
search_domains => $foreman_proxy::dhcp_search_domains,
failover => $failover,
}
if $foreman_proxy::dhcp_manage_acls {
package {'acl':
ensure => 'installed',
}
['/etc/dhcp', '/var/lib/dhcpd'].each |$path| {
exec { "Allow ${::foreman_proxy::user} to read ${path}":
command => "setfacl -R -m u:${::foreman_proxy::user}:rx ${path}",
path => '/usr/bin',
unless => "getfacl -p ${path} | grep user:${::foreman_proxy::user}:r-x",
require => Package['acl'],
}
}
}
if $failover {
class {'::dhcp::failover':
peer_address => $foreman_proxy::dhcp_peer_address,
role => $foreman_proxy::dhcp_node_type,
address => $foreman_proxy::dhcp_failover_address,
port => $foreman_proxy::dhcp_failover_port,
max_response_delay => $foreman_proxy::dhcp_max_response_delay,
max_unacked_updates => $foreman_proxy::dhcp_max_unacked_updates,
mclt => $foreman_proxy::dhcp_mclt,
load_split => $foreman_proxy::dhcp_load_split,
load_balance => $foreman_proxy::dhcp_load_balance,
omapi_key => $foreman_proxy::dhcp_key_secret,
}
}
}