From 3d479a45ec405b1e79dbd75d592b0c0407476ad1 Mon Sep 17 00:00:00 2001 From: Marek Hulan Date: Wed, 9 Jul 2025 19:33:19 +0000 Subject: [PATCH] Fixes #38558 - support for configuring WOL module --- manifests/config.pp | 2 ++ manifests/init.pp | 6 ++++++ manifests/module/wol.pp | 17 +++++++++++++++++ spec/classes/foreman_proxy__spec.rb | 20 +++++++++++++++++++- templates/wol.yml.erb | 7 +++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 manifests/module/wol.pp create mode 100644 templates/wol.yml.erb diff --git a/manifests/config.pp b/manifests/config.pp index 68b414202..65429de70 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -65,6 +65,8 @@ contain foreman_proxy::module::bmc + contain foreman_proxy::module::wol + contain foreman_proxy::module::dhcp foreman_proxy::provider { ['dhcp_isc', 'dhcp_libvirt']: } diff --git a/manifests/init.pp b/manifests/init.pp index 3d0fb244b..1af9c7432 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -219,6 +219,10 @@ # # $bmc_ssh_poweron:: BMC SSH poweron command. # +# $wol:: Enable WOL feature +# +# $wol_listen_on:: WOL proxy to listen on https, http, or both +# # $keyfile:: DNS server keyfile path # # $realm:: Enable realm management feature @@ -404,6 +408,8 @@ # lint:ignore:quoted_booleans String $bmc_ssh_poweron = 'false', # lint:endignore + Boolean $wol = false, + Foreman_proxy::ListenOn $wol_listen_on = 'https', Boolean $realm = false, Foreman_proxy::ListenOn $realm_listen_on = 'https', String $realm_provider = 'freeipa', diff --git a/manifests/module/wol.pp b/manifests/module/wol.pp new file mode 100644 index 000000000..385c3657f --- /dev/null +++ b/manifests/module/wol.pp @@ -0,0 +1,17 @@ +# @summary The built in WOL module +# +# @param enabled +# Whether the module is enabled or disabled. +# +# @param listen_on +# Where to listen on. +class foreman_proxy::module::wol ( + Boolean $enabled = $foreman_proxy::wol, + Foreman_proxy::ListenOn $listen_on = $foreman_proxy::wol_listen_on, +) { + foreman_proxy::module { 'wol': + enabled => $enabled, + feature => 'WOL', + listen_on => $listen_on, + } +} diff --git a/spec/classes/foreman_proxy__spec.rb b/spec/classes/foreman_proxy__spec.rb index 628242ba9..b20442517 100644 --- a/spec/classes/foreman_proxy__spec.rb +++ b/spec/classes/foreman_proxy__spec.rb @@ -96,7 +96,7 @@ 'logs', 'httpboot', 'puppet', 'puppet_proxy_puppet_api', 'puppetca', 'puppetca_http_api', 'puppetca_puppet_cert', 'puppetca_hostname_whitelisting', 'puppetca_token_whitelisting', - 'realm', 'templates', 'tftp' + 'realm', 'templates', 'tftp', 'wol' ].each do |cfile| should contain_file("#{etc_dir}/foreman-proxy/settings.d/#{cfile}.yml") .with_owner('root') @@ -151,6 +151,13 @@ ]) end + it 'should generate correct wol.yml' do + verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/wol.yml", [ + '---', + ':enabled: false', + ]) + end + it 'should generate correct dhcp.yml' do verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/dhcp.yml", [ '---', @@ -536,6 +543,17 @@ end end + context 'with wol' do + let(:params) { super().merge(wol: true) } + + it 'should enable wol' do + verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/wol.yml", [ + '---', + ':enabled: https', + ]) + end + end + context 'only http enabled' do let(:params) { super().merge(ssl: false, http: true) } diff --git a/templates/wol.yml.erb b/templates/wol.yml.erb new file mode 100644 index 000000000..fee1129b5 --- /dev/null +++ b/templates/wol.yml.erb @@ -0,0 +1,7 @@ +--- +# Can be true, false, or http/https to enable just one of the protocols +:enabled: <%= @module_enabled %> + +# Wake-on-LAN configuration +# The module sends standard WoL magic packets via UDP broadcast on port 9 +# No additional configuration is required as it uses the standard protocol