diff --git a/manifests/init.pp b/manifests/init.pp index d1faa6ee..e5084c45 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -133,9 +133,13 @@ # # $tftp_listen_on:: TFTP proxy to listen on https, http, or both # -# $tftp_syslinux_root:: Directory that hold syslinux files +# $tftp_syslinux_root:: Directory that hold syslinux files (deprecated, see $tftp_syslinux_filenames) # -# $tftp_syslinux_files:: Syslinux files to install on TFTP (copied from $tftp_syslinux_root) +# $tftp_syslinux_files:: Syslinux files to install on TFTP (copied from $tftp_syslinux_root, +# deprecated, see $tftp_syslinux_filenames) +# type:array +# +# $tftp_syslinux_filenames:: Syslinux files to install on TFTP (full paths) # type:array # # $tftp_root:: TFTP root directory @@ -293,6 +297,7 @@ $tftp_listen_on = $foreman_proxy::params::tftp_listen_on, $tftp_syslinux_root = $foreman_proxy::params::tftp_syslinux_root, $tftp_syslinux_files = $foreman_proxy::params::tftp_syslinux_files, + $tftp_syslinux_filenames = $foreman_proxy::params::tftp_syslinux_filenames, $tftp_root = $foreman_proxy::params::tftp_root, $tftp_dirs = $foreman_proxy::params::tftp_dirs, $tftp_servername = $foreman_proxy::params::tftp_servername, diff --git a/manifests/params.pp b/manifests/params.pp index 4134b66f..2d0102a0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -95,15 +95,33 @@ # TFTP settings - requires optional TFTP puppet module $tftp = true $tftp_listen_on = 'https' - case $::operatingsystem { - Debian,Ubuntu: { - $tftp_syslinux_root = '/usr/lib/syslinux' + + # TODO: remove these on the next major version bump + $tftp_syslinux_root = undef + $tftp_syslinux_files = undef + + case $::osfamily { + 'Debian': { + if ($::operatingsystem == 'Debian') and (versioncmp($::operatingsystemrelease, '8.0') >= 0) or + ($::operatingsystem == 'Ubuntu') and (versioncmp($::operatingsystemrelease, '14.10') >= 0) { + $tftp_syslinux_filenames = ['/usr/lib/PXELINUX/pxelinux.0', + '/usr/lib/syslinux/memdisk', + '/usr/lib/syslinux/modules/bios/chain.c32', + '/usr/lib/syslinux/modules/bios/menu.c32'] + } else { + $tftp_syslinux_filenames = ['/usr/lib/syslinux/chain.c32', + '/usr/lib/syslinux/menu.c32', + '/usr/lib/syslinux/memdisk', + '/usr/lib/syslinux/pxelinux.0'] + } } default: { - $tftp_syslinux_root = '/usr/share/syslinux' + $tftp_syslinux_filenames = ['/usr/share/syslinux/chain.c32', + '/usr/share/syslinux/menu.c32', + '/usr/share/syslinux/memdisk', + '/usr/share/syslinux/pxelinux.0'] } } - $tftp_syslinux_files = ['pxelinux.0','menu.c32','chain.c32','memdisk'] $tftp_root = $tftp::params::root $tftp_dirs = ["${tftp_root}/pxelinux.cfg","${tftp_root}/boot"] $tftp_servername = $::ipaddress_eth0 ? { diff --git a/manifests/tftp.pp b/manifests/tftp.pp index a7994861..67016c18 100644 --- a/manifests/tftp.pp +++ b/manifests/tftp.pp @@ -13,11 +13,22 @@ recurse => true; } - foreman_proxy::tftp::sync_file{$foreman_proxy::tftp_syslinux_files: - source_path => $foreman_proxy::tftp_syslinux_root, - target_path => $foreman_proxy::tftp_root, - require => Class['tftp::install']; + if $foreman_proxy::tftp_syslinux_files { + # TODO: remove on the next major version bump + foreman_proxy::tftp::sync_file{$foreman_proxy::tftp_syslinux_files: + source_path => $foreman_proxy::tftp_syslinux_root, + target_path => $foreman_proxy::tftp_root, + require => Class['tftp::install']; + } + + warning('foreman_proxy::tftp_syslinux_files is deprecated in favour of foreman_proxy::tftp_syslinux_filenames and will be removed') + } else { + foreman_proxy::tftp::copy_file{$foreman_proxy::tftp_syslinux_filenames: + target_path => $foreman_proxy::tftp_root, + require => Class['tftp::install']; + } } ensure_packages(['wget']) + } diff --git a/manifests/tftp/copy_file.pp b/manifests/tftp/copy_file.pp new file mode 100644 index 00000000..8858a3d7 --- /dev/null +++ b/manifests/tftp/copy_file.pp @@ -0,0 +1,12 @@ +# Copy a TFTP file +define foreman_proxy::tftp::copy_file( + $target_path, + $source_file = $title, +) { + private() + $filename = inline_template('<%= File.basename(@source_file) %>') + file {"${target_path}/${filename}": + ensure => 'present', + source => $source_file, + } +} diff --git a/manifests/tftp/sync_file.pp b/manifests/tftp/sync_file.pp index 0fe4f1bb..128e74cf 100644 --- a/manifests/tftp/sync_file.pp +++ b/manifests/tftp/sync_file.pp @@ -1,8 +1,11 @@ # Sync a TFTP file +# TODO: remove on the next major version bump define foreman_proxy::tftp::sync_file( $source_path, $target_path ) { + warning('foreman_proxy::tftp::sync_file is deprecated and will be removed') + file {"${target_path}/${name}": ensure => 'present', source => "${source_path}/${name}", diff --git a/metadata.json b/metadata.json index f9f5db85..5c70a19d 100644 --- a/metadata.json +++ b/metadata.json @@ -25,7 +25,7 @@ { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Fedora", "operatingsystemrelease": [ "19" ] }, - { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, + { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7", "8" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "12.04", "14.04" ] } ] } diff --git a/spec/classes/foreman_proxy__config__spec.rb b/spec/classes/foreman_proxy__config__spec.rb index 4da773ea..53e8f680 100644 --- a/spec/classes/foreman_proxy__config__spec.rb +++ b/spec/classes/foreman_proxy__config__spec.rb @@ -282,6 +282,80 @@ end end + context 'with TFTP enabled on Debian 7 (Wheezy)' do + let :facts do + { + :fqdn => 'host.example.org', + :ipaddress => '127.0.1.2', + :operatingsystem => 'Debian', + :operatingsystemrelease => '7.7', + :osfamily => 'Debian', + } + end + + let :pre_condition do + 'class {"foreman_proxy": + tftp => true, + }' + end + + it 'should copy the correct default files for Debian 7' do + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/chain.c32') + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/menu.c32') + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/memdisk') + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/pxelinux.0') + end + end + + context 'with TFTP enabled on Debian 8 (Jessie)' do + let :facts do + { + :fqdn => 'host.example.org', + :ipaddress => '127.0.1.2', + :operatingsystem => 'Debian', + :operatingsystemrelease => '8.0', + :osfamily => 'Debian', + } + end + + let :pre_condition do + 'class {"foreman_proxy": + tftp => true, + }' + end + + it 'should copy the correct default files for Debian 8' do + should contain_foreman_proxy__tftp__copy_file('/usr/lib/PXELINUX/pxelinux.0') + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/memdisk') + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/modules/bios/chain.c32') + should contain_foreman_proxy__tftp__copy_file('/usr/lib/syslinux/modules/bios/menu.c32') + end + end + + context 'with TFTP enabled and tftp_syslinux_filenames set' do + let :facts do + { + :fqdn => 'host.example.org', + :ipaddress => '127.0.1.2', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6.5', + :osfamily => 'RedHat', + } + end + + let :pre_condition do + 'class {"foreman_proxy": + tftp => true, + tftp_syslinux_filenames => [ "/my/file", "/my/anotherfile" ], + }' + end + + it 'should copy the given files' do + should contain_foreman_proxy__tftp__copy_file('/my/file') + should contain_foreman_proxy__tftp__copy_file('/my/anotherfile') + end + end + context 'with pupppetrun_provider set to mcollective' do let :facts do {