Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37121 - Automatically secure the DHCP OMAPI interface #827

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
#
# $dhcp_key_name:: DHCP key name
#
# $dhcp_key_secret:: DHCP password
# $dhcp_key_secret:: DHCP key secret. If not provided, a secret will be generated.
#
# $dhcp_omapi_port:: DHCP server OMAPI port
#
Expand Down Expand Up @@ -363,7 +363,7 @@
String $dhcp_server = '127.0.0.1',
Stdlib::Absolutepath $dhcp_config = $foreman_proxy::params::dhcp_config,
Stdlib::Absolutepath $dhcp_leases = $foreman_proxy::params::dhcp_leases,
Optional[String] $dhcp_key_name = undef,
String[1] $dhcp_key_name = 'omapi_key',
Optional[String] $dhcp_key_secret = undef,
Stdlib::Port $dhcp_omapi_port = 7911,
Optional[String] $dhcp_peer_address = undef,
Expand Down
31 changes: 22 additions & 9 deletions manifests/proxydhcp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,29 @@
$_dhcp_ipxefilename = undef
}

if $foreman_proxy::dhcp_key_secret {
# TODO parametrize
$dhcp_key_algorithm = undef
$dhcp_key_secret = $foreman_proxy::dhcp_key_secret
} else {
# TODO: ensure bind-utils is installed before dns::tsig_keygen runs
# TODO: if the function runs on a server, do you need it on the server? Or use Deferred?
$tsig_key = extlib::cache_data('theforeman', 'dhcp_omapi', dns::tsig_keygen($foreman_proxy::dhcp_key_name))
$dhcp_key_algorithm = $tsig_key['algorithm']
$dhcp_key_secret = $tsig_key['secret']
}

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,
ipxe_filename => $_dhcp_ipxefilename,
omapi_name => $foreman_proxy::dhcp_key_name,
omapi_key => $foreman_proxy::dhcp_key_secret,
conf_dir_mode => $conf_dir_mode,
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,
ipxe_filename => $_dhcp_ipxefilename,
omapi_name => $foreman_proxy::dhcp_key_name,
omapi_key => $dhcp_key_secret,
omapi_algorithm => $dhcp_key_algorithm,
conf_dir_mode => $conf_dir_mode,
}

dhcp::pool { $facts['networking']['domain']:
Expand Down
Loading