Skip to content

Commit

Permalink
syslinux package got split-up in Debian/jessie
Browse files Browse the repository at this point in the history
Closes GH-132
  • Loading branch information
mmoll authored and Dominic Cleal committed Feb 17, 2015
1 parent a260cdc commit 468eb0c
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 12 deletions.
9 changes: 7 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 23 additions & 5 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? {
Expand Down
19 changes: 15 additions & 4 deletions manifests/tftp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

}
12 changes: 12 additions & 0 deletions manifests/tftp/copy_file.pp
Original file line number Diff line number Diff line change
@@ -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,
}
}
3 changes: 3 additions & 0 deletions manifests/tftp/sync_file.pp
Original file line number Diff line number Diff line change
@@ -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}",
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] }
]
}
74 changes: 74 additions & 0 deletions spec/classes/foreman_proxy__config__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 468eb0c

Please sign in to comment.