diff --git a/manifests/init.pp b/manifests/init.pp index d9c2fa2a8..019541927 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 @@ -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, diff --git a/manifests/module/tftp.pp b/manifests/module/tftp.pp index dfaccf91a..73144f8bd 100644 --- a/manifests/module/tftp.pp +++ b/manifests/module/tftp.pp @@ -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': diff --git a/manifests/params.pp b/manifests/params.pp index 430df5201..e67249c3d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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') diff --git a/manifests/tftp.pp b/manifests/tftp.pp index 902344573..88661b51d 100644 --- a/manifests/tftp.pp +++ b/manifests/tftp.pp @@ -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, @@ -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, diff --git a/spec/classes/foreman_proxy__spec.rb b/spec/classes/foreman_proxy__spec.rb index 6c0d890e2..8442359a9 100644 --- a/spec/classes/foreman_proxy__spec.rb +++ b/spec/classes/foreman_proxy__spec.rb @@ -274,6 +274,7 @@ '---', ':enabled: false', ":tftproot: #{tftp_root}", + ':system_image_root: /var/lib/foreman-proxy/tftp/system_images', ]) end @@ -434,6 +435,7 @@ '---', ':enabled: https', ":tftproot: #{tftp_root}", + ':system_image_root: /var/lib/foreman-proxy/tftp/system_images', ]) end @@ -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 diff --git a/templates/tftp.yml.erb b/templates/tftp.yml.erb index 0cfa7c212..6a12fa561 100644 --- a/templates/tftp.yml.erb +++ b/templates/tftp.yml.erb @@ -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") %>