Skip to content

Commit fadca3d

Browse files
committed
Fixes #37121 - Automatically secure the DHCP OMAPI interface
The tsig-keygen command can be used to generate a TSIG key to secure the OMAPI communication.
1 parent c31f90c commit fadca3d

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

.fixtures.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ fixtures:
77
cron_core: "https://github.com/puppetlabs/puppetlabs-cron_core"
88
datacat: 'https://github.com/richardc/puppet-datacat'
99
dhcp: 'https://github.com/theforeman/puppet-dhcp'
10-
dns: 'https://github.com/theforeman/puppet-dns'
10+
dns:
11+
repo: 'https://github.com/ekohl/puppet-dns'
12+
branch: add-tsig-keygen
1113
extlib: 'https://github.com/voxpupuli/puppet-extlib'
1214
foreman: 'https://github.com/theforeman/puppet-foreman'
1315
puppet: 'https://github.com/theforeman/puppet-puppet'

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
#
164164
# $dhcp_key_name:: DHCP key name
165165
#
166-
# $dhcp_key_secret:: DHCP password
166+
# $dhcp_key_secret:: DHCP key secret. If not provided, a secret will be generated.
167167
#
168168
# $dhcp_omapi_port:: DHCP server OMAPI port
169169
#
@@ -363,7 +363,7 @@
363363
String $dhcp_server = '127.0.0.1',
364364
Stdlib::Absolutepath $dhcp_config = $foreman_proxy::params::dhcp_config,
365365
Stdlib::Absolutepath $dhcp_leases = $foreman_proxy::params::dhcp_leases,
366-
Optional[String] $dhcp_key_name = undef,
366+
String[1] $dhcp_key_name = 'omapi_key',
367367
Optional[String] $dhcp_key_secret = undef,
368368
Stdlib::Port $dhcp_omapi_port = 7911,
369369
Optional[String] $dhcp_peer_address = undef,

manifests/proxydhcp.pp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,29 @@
6262
$_dhcp_ipxefilename = undef
6363
}
6464

65+
if $foreman_proxy::dhcp_key_secret {
66+
# TODO parametrize
67+
$dhcp_key_algorithm = undef
68+
$dhcp_key_secret = $foreman_proxy::dhcp_key_secret
69+
} else {
70+
# TODO: ensure bind-utils is installed before dns::tsig_keygen runs
71+
# TODO: if the function runs on a server, do you need it on the server? Or use Deferred?
72+
$tsig_key = extlib::cache_data('theforeman', 'dhcp_omapi', dns::tsig_keygen($foreman_proxy::dhcp_key_name))
73+
$dhcp_key_algorithm = $tsig_key['algorithm']
74+
$dhcp_key_secret = $tsig_key['secret']
75+
}
76+
6577
class { 'dhcp':
66-
dnsdomain => $foreman_proxy::dhcp_option_domain,
67-
nameservers => $nameservers,
68-
interfaces => [$foreman_proxy::dhcp_interface] + $foreman_proxy::dhcp_additional_interfaces,
69-
pxeserver => $ip,
70-
pxefilename => $foreman_proxy::dhcp_pxefilename,
71-
ipxe_filename => $_dhcp_ipxefilename,
72-
omapi_name => $foreman_proxy::dhcp_key_name,
73-
omapi_key => $foreman_proxy::dhcp_key_secret,
74-
conf_dir_mode => $conf_dir_mode,
78+
dnsdomain => $foreman_proxy::dhcp_option_domain,
79+
nameservers => $nameservers,
80+
interfaces => [$foreman_proxy::dhcp_interface] + $foreman_proxy::dhcp_additional_interfaces,
81+
pxeserver => $ip,
82+
pxefilename => $foreman_proxy::dhcp_pxefilename,
83+
ipxe_filename => $_dhcp_ipxefilename,
84+
omapi_name => $foreman_proxy::dhcp_key_name,
85+
omapi_key => $dhcp_key_secret,
86+
omapi_algorithm => $dhcp_key_algorithm,
87+
conf_dir_mode => $conf_dir_mode,
7588
}
7689

7790
dhcp::pool { $facts['networking']['domain']:

0 commit comments

Comments
 (0)