Skip to content

Commit

Permalink
make syslinux package management optional
Browse files Browse the repository at this point in the history
when finer control over the syslinux package is required, dedicated
puppet modules can be used. given that the tftp and the pxe module
would then end up managing the same package, one must not in order
for the catalog to compile.
this change make the syslinux package management optional, but keeps
the current behaviour for backwards compatibility.
  • Loading branch information
UiP9AV6Y authored and ekohl committed Jun 27, 2023
1 parent cc74966 commit d618948
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions data/common.yaml
@@ -1,2 +1,3 @@
---
tftp::manage_root_dir: true
tftp::manage_syslinux_package: true
2 changes: 2 additions & 0 deletions manifests/init.pp
Expand Up @@ -16,13 +16,15 @@
# @param root Configures the root directory for the TFTP server
# @param package Name of the TFTP server package
# @param syslinux_package Name of the syslinux package, essential for pxe boot
# @param manage_syslinux_package manages the syslinux package, defaults to true
# @param manage_root_dir manages the root dir, which tftpd will serve, defaults to true
# @param service Name of the TFTP service, when daemon is true
# @param service_provider Override TFTP service provider, when daemon is true
class tftp (
Stdlib::Absolutepath $root,
String $package,
Variant[String, Array[String]] $syslinux_package,
Boolean $manage_syslinux_package,
Boolean $manage_root_dir,
Optional[String] $service = undef,
Optional[String] $service_provider = undef,
Expand Down
6 changes: 4 additions & 2 deletions manifests/install.pp
Expand Up @@ -6,7 +6,9 @@
alias => 'tftp-server',
}

package { $tftp::syslinux_package:
ensure => installed,
if $tftp::manage_syslinux_package {
package { $tftp::syslinux_package:
ensure => installed,
}
}
}
28 changes: 23 additions & 5 deletions spec/classes/init_spec.rb
Expand Up @@ -4,6 +4,14 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
let(:syslinux_package) do
case facts[:osfamily]
when 'Debian'
%w[syslinux-common pxelinux]
else
%w[syslinux]
end
end

it { should compile.with_all_deps }

Expand All @@ -27,11 +35,8 @@
.with_ensure('installed')
.with_alias('tftp-server')

if facts[:operatingsystem] == 'Debian' || facts[:operatingsystem] == 'Ubuntu'
should contain_package('pxelinux').with_ensure('installed')
should contain_package('syslinux-common').with_ensure('installed')
else
should contain_package('syslinux').with_ensure('installed')
syslinux_package.each do |p|
should contain_package(p).with_ensure('installed')
end
end

Expand Down Expand Up @@ -94,6 +99,19 @@
should contain_package('my-own-syslinux').with_ensure('installed')
end
end

context 'with syslinux package management set to false' do
let :params do
{
manage_syslinux_package: false
}
end
it 'should not install a syslinux package' do
syslinux_package.each do |p|
should_not contain_package(p)
end
end
end
end
end

Expand Down

0 comments on commit d618948

Please sign in to comment.