diff --git a/manifests/init.pp b/manifests/init.pp index 4b9e65af3..a4fb1845d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -346,8 +346,8 @@ Boolean $tftp_managed = $foreman_proxy::params::tftp_managed, Boolean $tftp_manage_wget = $foreman_proxy::params::tftp_manage_wget, Array[Stdlib::Absolutepath] $tftp_syslinux_filenames = $foreman_proxy::params::tftp_syslinux_filenames, - Stdlib::Absolutepath $tftp_root = $foreman_proxy::params::tftp_root, - Array[Stdlib::Absolutepath] $tftp_dirs = $foreman_proxy::params::tftp_dirs, + Optional[Stdlib::Absolutepath] $tftp_root = $foreman_proxy::params::tftp_root, + Optional[Array[Stdlib::Absolutepath]] $tftp_dirs = $foreman_proxy::params::tftp_dirs, Optional[String] $tftp_servername = $foreman_proxy::params::tftp_servername, Boolean $tftp_replace_grub2_cfg = $foreman_proxy::params::tftp_replace_grub2_cfg, Boolean $dhcp = $foreman_proxy::params::dhcp, diff --git a/manifests/module/httpboot.pp b/manifests/module/httpboot.pp index 0a7aac71b..5e28c7044 100644 --- a/manifests/module/httpboot.pp +++ b/manifests/module/httpboot.pp @@ -8,7 +8,12 @@ class foreman_proxy::module::httpboot ( Boolean $enabled = $foreman_proxy::httpboot, Foreman_proxy::ListenOn $listen_on = $foreman_proxy::httpboot_listen_on, + Optional[Stdlib::Absolutepath] $root_dir = $foreman_proxy::tftp_root, ) { + if $enabled { + assert_type(NotUndef, $root_dir) + } + foreman_proxy::module { 'httpboot': enabled => $enabled, feature => 'HTTPBoot', diff --git a/manifests/module/tftp.pp b/manifests/module/tftp.pp index a9a286d2f..1593594dd 100644 --- a/manifests/module/tftp.pp +++ b/manifests/module/tftp.pp @@ -8,7 +8,12 @@ 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, ) { + if $enabled { + assert_type(NotUndef, $tftproot) + } + foreman_proxy::module { 'tftp': enabled => $enabled, listen_on => $listen_on, diff --git a/manifests/params.pp b/manifests/params.pp index 05e11944a..a4a8be81e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,7 +1,6 @@ # @summary The default parameters for the foreman proxy # @api private class foreman_proxy::params inherits foreman_proxy::globals { - $tftp_root = lookup('tftp::root') $lower_fqdn = downcase($facts['networking']['fqdn']) case $facts['os']['family'] { @@ -227,7 +226,8 @@ $tftp_listen_on = 'https' $tftp_managed = true $tftp_manage_wget = true - $tftp_dirs = ["${tftp_root}/pxelinux.cfg","${tftp_root}/grub","${tftp_root}/grub2","${tftp_root}/boot","${tftp_root}/ztp.cfg","${tftp_root}/poap.cfg"] + $tftp_root = lookup('tftp::root', undef, undef, undef) + $tftp_dirs = undef $tftp_servername = undef $tftp_replace_grub2_cfg = false diff --git a/manifests/plugin/discovery/params.pp b/manifests/plugin/discovery/params.pp index b83823481..96135ca16 100644 --- a/manifests/plugin/discovery/params.pp +++ b/manifests/plugin/discovery/params.pp @@ -1,10 +1,8 @@ # Default parameters for foreman_proxy::plugin::discovery # @api private class foreman_proxy::plugin::discovery::params { - include foreman_proxy::params - $install_images = false - $tftp_root = $foreman_proxy::params::tftp_root + $tftp_root = lookup('tftp::root') $source_url = 'http://downloads.theforeman.org/discovery/releases/latest/' $image_name = 'fdi-image-latest.tar' } diff --git a/manifests/tftp.pp b/manifests/tftp.pp index f4bead7d4..37d10cc15 100644 --- a/manifests/tftp.pp +++ b/manifests/tftp.pp @@ -1,19 +1,21 @@ # @summary Set up the tftp service # @api private class foreman_proxy::tftp ( - $user = $foreman_proxy::user, - $root = $foreman_proxy::tftp_root, - $directories = $foreman_proxy::tftp_dirs, - $syslinux_filenames = $foreman_proxy::tftp_syslinux_filenames, - $manage_wget = $foreman_proxy::tftp_manage_wget, - $wget_version = $foreman_proxy::ensure_packages_version, - $tftp_replace_grub2_cfg = $foreman_proxy::tftp_replace_grub2_cfg, + String[1] $user = $foreman_proxy::user, + Optional[Stdlib::Absolutepath] $root = $foreman_proxy::tftp_root, + Optional[Array[Stdlib::Absolutepath]] $directories = $foreman_proxy::tftp_dirs, + Array[Stdlib::Absolutepath] $syslinux_filenames = $foreman_proxy::tftp_syslinux_filenames, + Boolean $manage_wget = $foreman_proxy::tftp_manage_wget, + String[1] $wget_version = $foreman_proxy::ensure_packages_version, + Boolean $tftp_replace_grub2_cfg = $foreman_proxy::tftp_replace_grub2_cfg, ) { class { 'tftp': root => $root, } - file { $directories: + $dirs = pick($directories, prefix(['pxelinux.cfg','grub','grub2','boot','ztp.cfg','poap.cfg'], "${tftp::root}/")) + + file { $dirs: ensure => directory, owner => $user, mode => '0644', @@ -21,7 +23,7 @@ recurse => true, } - file { "${root}/grub2/grub.cfg": + file { "${tftp::root}/grub2/grub.cfg": ensure => file, owner => $user, mode => '0644', @@ -31,7 +33,7 @@ $syslinux_filenames.each |$source_file| { $filename = basename($source_file) - file {"${root}/${filename}": + file {"${tftp::root}/${filename}": ensure => file, owner => $user, mode => '0644', @@ -45,7 +47,7 @@ } class { 'foreman_proxy::tftp::netboot': - root => $root, + root => $tftp::root, require => File[$directories], } contain foreman_proxy::tftp::netboot diff --git a/templates/httpboot.yml.erb b/templates/httpboot.yml.erb index 4744f24a5..e80cc40cd 100644 --- a/templates/httpboot.yml.erb +++ b/templates/httpboot.yml.erb @@ -7,4 +7,4 @@ # configuration files deployment. :enabled: <%= @module_enabled %> -:root_dir: <%= scope.lookupvar('foreman_proxy::tftp_root') %> +:root_dir: <%= scope.lookupvar('foreman_proxy::module::httpboot::root_dir') %> diff --git a/templates/tftp.yml.erb b/templates/tftp.yml.erb index e913d8cc9..2a2f1dede 100644 --- a/templates/tftp.yml.erb +++ b/templates/tftp.yml.erb @@ -1,6 +1,6 @@ --- # TFTP management :enabled: <%= @module_enabled %> -:tftproot: <%= scope.lookupvar("foreman_proxy::tftp_root") %> +:tftproot: <%= scope.lookupvar("foreman_proxy::module::tftp::tftproot") %> # Defines the TFTP Servername to use, overrides the name in the subnet declaration <%= '#' if [nil, :undefined, :undef].include?(scope.lookupvar("foreman_proxy::tftp_servername")) %>:tftp_servername: <%= scope.lookupvar("foreman_proxy::tftp_servername") %>