Skip to content

Commit 1e45b6b

Browse files
hugendudelekohl
authored andcommitted
Fixes #33549 - Set dhcp iPXE filename
If no value is set, the template URL is taken if the template feature is activated.
1 parent 2c553d3 commit 1e45b6b

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

manifests/init.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@
157157
#
158158
# $dhcp_pxefilename:: DHCP "filename" value, defaults otherwise to pxelinux.0
159159
#
160+
# $dhcp_ipxefilename:: iPXE DHCP "filename" value, If not specified, it's determined dynamically.
161+
# When the templates feature is enabled, the template_url is used.
162+
#
163+
# $dhcp_ipxe_bootstrap:: Enable or disable iPXE bootstrap(discovery) feature
164+
#
160165
# $dhcp_network:: DHCP server network value, defaults otherwise to value based on IP of dhcp_interface
161166
#
162167
# $dhcp_netmask:: DHCP server netmask value, defaults otherwise to value based on IP of dhcp_interface
@@ -358,6 +363,8 @@
358363
Variant[Undef, Boolean, String] $dhcp_range = undef,
359364
Optional[String] $dhcp_pxeserver = undef,
360365
String $dhcp_pxefilename = 'pxelinux.0',
366+
Optional[String[1]] $dhcp_ipxefilename = undef,
367+
Boolean $dhcp_ipxe_bootstrap = false,
361368
Optional[String] $dhcp_network = undef,
362369
Optional[String] $dhcp_netmask = undef,
363370
String $dhcp_nameservers = 'default',

manifests/proxydhcp.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,24 @@
4747
$conf_dir_mode = undef
4848
}
4949

50+
if $foreman_proxy::dhcp_ipxefilename {
51+
$_dhcp_ipxefilename = $foreman_proxy::dhcp_ipxefilename
52+
} elsif $foreman_proxy::templates and $foreman_proxy::dhcp_ipxe_bootstrap {
53+
$_dhcp_ipxefilename = "${foreman_proxy::template_url}/unattended/iPXE?bootstrap=1"
54+
} elsif $foreman_proxy::templates {
55+
$_dhcp_ipxefilename = "${foreman_proxy::template_url}/unattended/iPXE"
56+
} else {
57+
$_dhcp_ipxefilename = undef
58+
}
59+
60+
5061
class { 'dhcp':
5162
dnsdomain => $foreman_proxy::dhcp_option_domain,
5263
nameservers => $nameservers,
5364
interfaces => [$foreman_proxy::dhcp_interface] + $foreman_proxy::dhcp_additional_interfaces,
5465
pxeserver => $ip,
5566
pxefilename => $foreman_proxy::dhcp_pxefilename,
67+
ipxe_filename => $_dhcp_ipxefilename,
5668
omapi_name => $foreman_proxy::dhcp_key_name,
5769
omapi_key => $foreman_proxy::dhcp_key_secret,
5870
conf_dir_mode => $conf_dir_mode,

spec/classes/foreman_proxy__proxydhcp__spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
.with_interfaces(['eth0'])
3838
.with_pxeserver('192.0.2.10')
3939
.with_pxefilename('pxelinux.0')
40+
.with_ipxe_filename(nil)
4041
end
4142

4243
it do
@@ -210,6 +211,29 @@
210211

211212
it { should compile.and_raise_error(/Could not get the ip address from fact ipaddress_doesnotexist/) }
212213
end
214+
215+
context 'with templates' do
216+
let(:facts) { facts }
217+
let(:params) { super().merge(templates: true) }
218+
219+
it { should compile.with_all_deps }
220+
it { should contain_class('dhcp').with_ipxe_filename('http://foo.example.com:8000/unattended/iPXE') }
221+
222+
context 'with bootstrap' do
223+
let(:params) { super().merge(dhcp_ipxe_bootstrap: true) }
224+
225+
it { should compile.with_all_deps }
226+
it { should contain_class('dhcp').with_ipxe_filename('http://foo.example.com:8000/unattended/iPXE?bootstrap=1') }
227+
end
228+
229+
context 'with explicit parameter' do
230+
let(:params) { super().merge(dhcp_ipxefilename: 'http://customapi.example.com/boot') }
231+
232+
it { should compile.with_all_deps }
233+
it { should contain_class('dhcp').with_ipxe_filename('http://customapi.example.com/boot') }
234+
end
235+
end
236+
213237
end
214238
end
215239
end

0 commit comments

Comments
 (0)