From 084c0e54a39f77d8ef8bedba4a8903d2076559b0 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 6 Sep 2022 21:00:43 +0900 Subject: [PATCH] pxe: Allow disabling http server This change introduces a new option to disable resources to set up http server for ipxe boot. This is useful, when ipxe boot interface is not used or users have their own external tooling to maintain the http server. Change-Id: Ic767795442ee68ce8dda6bc8b53493ac17f6f40c --- manifests/pxe.pp | 38 +++++++++++-------- .../manage_http_server-bc9a073ba0c997ee.yaml | 6 +++ spec/classes/ironic_pxe_spec.rb | 12 ++++++ 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/manage_http_server-bc9a073ba0c997ee.yaml diff --git a/manifests/pxe.pp b/manifests/pxe.pp index 4b61113b..ae843f35 100644 --- a/manifests/pxe.pp +++ b/manifests/pxe.pp @@ -79,6 +79,10 @@ # (optional) Log facility of the dnsmasq process to server tftp server. # Defaults to undef # +# [*manage_http_server*] +# (optional) Set up Apache HTTP Server. +# Defaults to true +# class ironic::pxe ( $package_ensure = 'present', $tftp_root = '/tftpboot', @@ -93,6 +97,7 @@ class ironic::pxe ( $uefi_pxe_bootfile_name = 'bootx64.efi', $tftp_use_xinetd = $::ironic::params::xinetd_available, $dnsmasq_log_facility = undef, + $manage_http_server = true, ) inherits ironic::params { include ironic::deps @@ -136,15 +141,6 @@ class ironic::pxe ( tag => 'ironic-tftp-file', } - file { $http_root_real: - ensure => 'directory', - seltype => 'httpd_sys_content_t', - owner => $::ironic::params::user, - group => $::ironic::params::group, - require => Anchor['ironic::config::begin'], - before => Anchor['ironic::config::end'], - } - if $tftp_use_xinetd { if ! $::ironic::params::xinetd_available { fail('xinetd is not available in this distro. Please use tftp_use_xinetd=false') @@ -320,12 +316,24 @@ class ironic::pxe ( File["${tftp_root_real}"] -> File<| tag == 'ironic-tftp-file' |> - include apache + # HTTP server + if $manage_http_server { + file { $http_root_real: + ensure => 'directory', + seltype => 'httpd_sys_content_t', + owner => $::ironic::params::user, + group => $::ironic::params::group, + require => Anchor['ironic::config::begin'], + before => Anchor['ironic::config::end'], + } - apache::vhost { 'ipxe_vhost': - priority => 10, - options => ['Indexes','FollowSymLinks'], - docroot => $http_root_real, - port => $http_port_real, + include apache + + apache::vhost { 'ipxe_vhost': + priority => 10, + options => ['Indexes','FollowSymLinks'], + docroot => $http_root_real, + port => $http_port_real, + } } } diff --git a/releasenotes/notes/manage_http_server-bc9a073ba0c997ee.yaml b/releasenotes/notes/manage_http_server-bc9a073ba0c997ee.yaml new file mode 100644 index 00000000..7bf6af70 --- /dev/null +++ b/releasenotes/notes/manage_http_server-bc9a073ba0c997ee.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The ``ironic::pxe::manage_http_server`` parameter has been added. When + this parameter is set to ``false``, the ``ironic::pxe`` class does not + manage the Apache HTTP Server. diff --git a/spec/classes/ironic_pxe_spec.rb b/spec/classes/ironic_pxe_spec.rb index ad172d4f..665893a0 100644 --- a/spec/classes/ironic_pxe_spec.rb +++ b/spec/classes/ironic_pxe_spec.rb @@ -223,6 +223,18 @@ describe 'ironic::pxe' do is_expected.not_to contain_file('/var/lib/ironic/tftpboot/chain.c32') end end + + context 'when http server disabled' do + before :each do + params.merge!( + :manage_http_server => false, + ) + end + it 'should not configure http server' do + is_expected.not_to contain_class('apache') + is_expected.not_to contain_apache__vhost('ipxe_vhost') + end + end end shared_examples_for 'ironic pxe with xinetd' do