Skip to content

Commit

Permalink
Fixes #35851 - Add parameter tftp system_image_root
Browse files Browse the repository at this point in the history
Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
  • Loading branch information
bastian-src and ekohl committed Dec 14, 2022
1 parent f247991 commit a201326
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
#
# $tftp_replace_grub2_cfg:: Determines if grub2.cfg will be replaced
#
# $system_image_root:: TFTP system image root directory
#
# $dhcp:: Enable DHCP feature
#
# $dhcp_listen_on:: DHCP proxy to listen on https, http, or both
Expand Down Expand Up @@ -334,6 +336,7 @@
Boolean $tftp_managed = true,
Boolean $tftp_manage_wget = true,
Optional[Stdlib::Absolutepath] $tftp_root = $foreman_proxy::params::tftp_root,
Optional[Stdlib::Absolutepath] $system_image_root = $foreman_proxy::params::system_image_root,
Optional[Array[Stdlib::Absolutepath]] $tftp_dirs = undef,
Optional[String] $tftp_servername = undef,
Boolean $tftp_replace_grub2_cfg = false,
Expand Down
6 changes: 6 additions & 0 deletions manifests/module/tftp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@
#
# @param tftproot
# The root directory to use. This is required if the module is enabled.
#
# @param system_image_root
# The system image root directory to use. This is required if the module
# is supposed to download and extract OS image files.
class foreman_proxy::module::tftp (
Boolean $enabled = $foreman_proxy::tftp,
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::tftp_listen_on,
Optional[Stdlib::Absolutepath] $tftproot = $foreman_proxy::tftp_root,
Optional[Stdlib::Absolutepath] $system_image_root = $foreman_proxy::system_image_root,
) {
if $enabled {
assert_type(NotUndef, $tftproot)
assert_type(NotUndef, $system_image_root)
}

foreman_proxy::module { 'tftp':
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@

# TFTP settings - requires optional TFTP puppet module
$tftp_root = lookup('tftp::root', undef, undef, undef)
$system_image_root = '/var/lib/foreman-proxy/tftp/system_images'

# DHCP settings - requires optional DHCP puppet module
$dhcp_interface = pick(fact('networking.primary'), 'eth0')
Expand Down
7 changes: 7 additions & 0 deletions manifests/tftp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class foreman_proxy::tftp (
String[1] $user = $foreman_proxy::user,
Optional[Stdlib::Absolutepath] $root = $foreman_proxy::tftp_root,
Optional[Stdlib::Absolutepath] $system_image_root = $foreman_proxy::tftp_system_image_root,
Optional[Array[Stdlib::Absolutepath]] $directories = $foreman_proxy::tftp_dirs,
Array[Stdlib::Absolutepath] $syslinux_filenames = $foreman_proxy::params::tftp_syslinux_filenames,
Boolean $manage_wget = $foreman_proxy::tftp_manage_wget,
Expand All @@ -24,6 +25,12 @@
recurse => true,
}

file { $system_image_root:
ensure => directory,
owner => $user,
mode => '0644',
}

file { "${tftp::root}/grub2/grub.cfg":
ensure => file,
owner => $user,
Expand Down
5 changes: 4 additions & 1 deletion spec/classes/foreman_proxy__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
'---',
':enabled: false',
":tftproot: #{tftp_root}",
':system_image_root: /var/lib/foreman-proxy/tftp/system_images',
])
end

Expand Down Expand Up @@ -434,6 +435,7 @@
'---',
':enabled: https',
":tftproot: #{tftp_root}",
':system_image_root: /var/lib/foreman-proxy/tftp/system_images',
])
end

Expand Down Expand Up @@ -462,7 +464,8 @@
'---',
':enabled: https',
':tftproot: /tftproot',
':tftp_servername: 127.0.1.1'
':tftp_servername: 127.0.1.1',
':system_image_root: /var/lib/foreman-proxy/tftp/system_images',
])
end
end
Expand Down
3 changes: 3 additions & 0 deletions templates/tftp.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
# Defines the default certificate action for certificate checking.
# When false, the argument --no-check-certificate will be used.
#:verify_server_cert: true

# Defines the default folder to provide system images.
:system_image_root: <%= scope.lookupvar("foreman_proxy::module::tftp::system_image_root") %>

0 comments on commit a201326

Please sign in to comment.