Showing with 56 additions and 55 deletions.
  1. +9 −0 CHANGELOG.md
  2. +0 −1 Gemfile
  3. +1 −0 data/common.yaml
  4. +10 −11 manifests/config.pp
  5. +7 −4 manifests/init.pp
  6. +3 −6 manifests/install.pp
  7. +6 −10 manifests/service.pp
  8. +1 −1 metadata.json
  9. +2 −2 spec/acceptance/tftp_redhat_spec.rb
  10. +2 −2 spec/acceptance/tftp_spec.rb
  11. +15 −18 spec/classes/init_spec.rb
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [4.3.0](https://github.com/theforeman/puppet-tftp/tree/4.3.0) (2018-10-15)

[Full Changelog](https://github.com/theforeman/puppet-tftp/compare/4.2.1...4.3.0)

**Implemented enhancements:**

- Fixes [\#25190](https://projects.theforeman.org/issues/25190) - Allow overriding the tftp map source [\#82](https://github.com/theforeman/puppet-tftp/pull/82) ([ekohl](https://github.com/ekohl))
- Simplify service class & contain classes [\#80](https://github.com/theforeman/puppet-tftp/pull/80) ([ekohl](https://github.com/ekohl))

## [4.2.1](https://github.com/theforeman/puppet-tftp/tree/4.2.1) (2018-10-04)

[Full Changelog](https://github.com/theforeman/puppet-tftp/compare/4.2.0...4.2.1)
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ gem 'rspec-puppet', '~> 2.3'
gem 'rspec-puppet-facts', '>= 1.7'
gem 'puppetlabs_spec_helper', '>= 2.1.1'
gem 'puppet-lint', '>= 2'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-classes_and_types_beginning_with_digits-check'
gem 'puppet-lint-empty_string-check'
gem 'puppet-lint-file_ensure-check'
Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
tftp::manage_root_dir: true
tftp::map_source: puppet:///modules/tftp/tftpd.map
21 changes: 10 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Configure TFTP
class tftp::config {

if $::tftp::manage_root_dir {
ensure_resource('file', $::tftp::root, {'ensure' => 'directory'})
if $tftp::manage_root_dir {
ensure_resource('file', $tftp::root, {'ensure' => 'directory'})
}

if $::tftp::daemon {
if $::osfamily =~ /^(FreeBSD|DragonFly)$/ {
if $tftp::daemon {
if $facts['osfamily'] =~ /^(FreeBSD|DragonFly)$/ {
augeas { 'set root directory':
context => '/files/etc/rc.conf',
changes => "set tftpd_flags '\"-s ${::tftp::root}\"'",
changes => "set tftpd_flags '\"-s ${tftp::root}\"'",
}
}
} else {
include ::xinetd
include xinetd

xinetd::service { 'tftp':
port => '69',
server => '/usr/sbin/in.tftpd',
server_args => "-v -s ${::tftp::root} -m /etc/tftpd.map",
server_args => "-v -s ${tftp::root} -m /etc/tftpd.map",
socket_type => 'dgram',
protocol => 'udp',
cps => '100 2',
Expand All @@ -27,14 +26,14 @@
}

file {'/etc/tftpd.map':
source => "puppet:///modules/${module_name}/tftpd.map",
source => $tftp::map_source,
mode => '0644',
show_diff => false, # Puppet explodes with 'Error: invalid byte sequence in UTF-8' when trying to display the diff
notify => Class['xinetd'],
}

if $::tftp::manage_root_dir {
File[$::tftp::root] ~> Class['xinetd']
if $tftp::manage_root_dir {
File[$tftp::root] ~> Class['xinetd']
}
}
}
11 changes: 7 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# @param syslinux_package Name of the syslinux package, essential for pxe boot
# @param daemon Runs a TFTP service when true, configures xinetd when false
# @param manage_root_dir manages the root dir, which tftpd will serve, defaults to true
# @param map_source The source URL of the mapping file
# @param service Name of the TFTP service, when daemon is true
# @param service_provider Override TFTP service provider, when daemon is true
class tftp (
Expand All @@ -31,12 +32,14 @@
Variant[String, Array[String]] $syslinux_package,
Boolean $daemon,
Boolean $manage_root_dir,
String $map_source,
Optional[String] $service = undef,
Optional[String] $service_provider = undef,
) {
contain tftp::install
contain tftp::config
contain tftp::service

class {'::tftp::install':}
-> class {'::tftp::config':}
~> class {'::tftp::service':}
-> Class['::tftp']
Class['tftp::install'] -> Class['tftp::config']
Class['tftp::install', 'tftp::config'] ~> Class['tftp::service']
}
9 changes: 3 additions & 6 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Install TFTP
class tftp::install (
$package = $::tftp::package,
$syslinux_package = $::tftp::syslinux_package,
) {
package { $package:
class tftp::install {
package { $tftp::package:
ensure => installed,
alias => 'tftp-server',
}

package { $syslinux_package:
package { $tftp::syslinux_package:
ensure => installed,
}
}
16 changes: 6 additions & 10 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
class tftp::service {

# No service needed if not daemonized
case $tftp::daemon {
false: { }
default: {
service { $tftp::service:
ensure => running,
enable => true,
alias => 'tftpd',
provider => $::tftp::service_provider,
subscribe => Class['tftp::config'],
}
if $tftp::daemon {
service { $tftp::service:
ensure => running,
enable => true,
alias => 'tftpd',
provider => $tftp::service_provider,
}
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theforeman-tftp",
"version": "4.2.1",
"version": "4.3.0",
"author": "theforeman",
"summary": "TFTP server configuration",
"license": "GPL-3.0+",
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/tftp_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

let(:pp) do
<<-EOS
class { '::tftp':
class { 'tftp':
daemon => true,
}
file { "${::tftp::root}/test":
file { "${tftp::root}/test":
ensure => file,
content => 'clap your hands',
}
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/tftp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

let(:pp) do
<<-EOS
class { '::tftp': }
class { 'tftp': }
file { "${::tftp::root}/test":
file { "${tftp::root}/test":
ensure => file,
content => 'do the happy dance',
}
Expand Down
33 changes: 15 additions & 18 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@
end

it 'should contain the service' do
should contain_service('tftpd').with({
:ensure => 'running',
:enable => true,
:alias => 'tftpd',
:subscribe => 'Class[Tftp::Config]',
})
should contain_service('tftpd')
.with_ensure('running')
.with_enable('true')
.with_alias('tftpd')
.that_subscribes_to('Class[Tftp::Config]')
end
elsif facts[:osfamily] == 'Archlinux'
it 'should not configure xinetd' do
Expand All @@ -86,12 +85,11 @@
end

it 'should contain the service' do
should contain_service('tftpd.socket').with({
:ensure => 'running',
:enable => true,
:alias => 'tftpd',
:subscribe => 'Class[Tftp::Config]',
})
should contain_service('tftpd.socket')
.with_ensure('running')
.with_enable('true')
.with_alias('tftpd')
.that_subscribes_to('Class[Tftp::Config]')
end

else
Expand All @@ -101,12 +99,11 @@
end

it 'should contain the service' do
should contain_service('tftpd-hpa').with({
:ensure => 'running',
:enable => true,
:alias => 'tftpd',
:subscribe => 'Class[Tftp::Config]',
})
should contain_service('tftpd-hpa')
.with_ensure('running')
.with_enable('true')
.with_alias('tftpd')
.that_subscribes_to('Class[Tftp::Config]')
end

if facts[:operatingsystem] == 'Ubuntu' && facts[:operatingsystemrelease] == '16.04'
Expand Down