Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [1.0.1]
### Changed
- tftp class parameters signature to include ensure and enable as parameters.

## [1.0.0]
### Added
- Add puppet 4 and 5
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Parameters:
* port: bind port, default 69.
* options: service option, default --secure.
* inetd: run service via xinetd, default true.
* ensure: ensure service state (running)
* enable: define whether the service should start at boot (true)

Example:

Expand Down
16 changes: 11 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# [*port*]: tftp service bind port (default 69).
# [*options*]: tftp service bind port (default 69).
# [*inetd*]: Run as an xinetd service instead of standalone daemon (false)
# [*ensure*]: Ensure service state (running)
# [*enable*]: Define whether the service should start at boot (true)
#
# Actions:
#
Expand All @@ -18,9 +20,11 @@
# Usage:
#
# class { 'tftp':
# directory => '/opt/tftp',
# address => $::ipaddress,
# options => '--ipv6 --timeout 60',
# directory => '/opt/tftp',
# address => $::ipaddress,
# options => '--ipv6 --timeout 60',
# ensure => running,
# enable => true,
# }
#
class tftp (
Expand All @@ -30,6 +34,8 @@
$port = $tftp::params::port,
$options = $tftp::params::options,
$inetd = $tftp::params::inetd,
$ensure = $tftp::params::ensure,
$enable = $tftp::params::enable,
$package = $tftp::params::package,
$binary = $tftp::params::binary,
$defaults = $tftp::params::defaults,
Expand Down Expand Up @@ -73,8 +79,8 @@
$svc_ensure = stopped
$svc_enable = false
} else {
$svc_ensure = running
$svc_enable = true
$svc_ensure = $ensure
$svc_enable = $enable
}

$start = $tftp::params::provider ? {
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
$options = '--secure'
$binary = '/usr/sbin/in.tftpd'
$inetd = true
$ensure = running
$enable = true

case $::osfamily {
'debian': {
Expand Down
124 changes: 118 additions & 6 deletions spec/classes/tftp_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spec_helper'
describe 'tftp', :type => :class do

describe 'when deploying on debian as standalone' do
describe 'when deploying on debian as standalone with default params' do
let(:facts) { { :operatingsystem => 'Debian',
:osfamily => 'Debian',
:path => '/usr/local/bin:/usr/bin:/bin', } }
let(:params) { { :inetd => false, } }
let(:params) { { :inetd => false } }
it {
should contain_file('/etc/default/tftpd-hpa')
should contain_package('tftpd-hpa')
Expand All @@ -18,7 +18,28 @@
}
end

describe 'when deploying on ubuntu 14.04 as standalone' do

describe 'when deploying on debian as standalone with service disabled' do
let(:facts) { { :operatingsystem => 'Debian',
:osfamily => 'Debian',
:path => '/usr/local/bin:/usr/bin:/bin', } }

let(:params) { { :inetd => false, :enable => false, :ensure => 'stopped',} }
it {
should contain_file('/etc/default/tftpd-hpa')
should contain_package('tftpd-hpa')
should contain_service('tftpd-hpa').with({
'ensure' => 'stopped',
'enable' => false,
'hasstatus' => false,
'provider' => nil,
})
}
end



describe 'when deploying on ubuntu 14.04 as standalone with default params' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '14.04',
Expand All @@ -36,7 +57,25 @@
}
end

describe 'when deploying on ubuntu 14.10 as standalone' do
describe 'when deploying on ubuntu 14.04 as standalone with service disabled' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '14.04',
:path => '/usr/local/bin:/usr/bin:/bin', } }
let(:params) { { :inetd => false, :ensure => 'stopped', :enable => false,} }
it {
should contain_package('tftpd-hpa')
should contain_file('/etc/default/tftpd-hpa')
should contain_service('tftpd-hpa').with({
'ensure' => 'stopped',
'enable' => false,
'hasstatus' => true,
'provider' => 'upstart',
})
}
end

describe 'when deploying on ubuntu 14.10 as standalone with default params' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '14.10',
Expand All @@ -54,7 +93,25 @@
}
end

describe 'when deploying on ubuntu 15.04 or greater as standalone' do
describe 'when deploying on ubuntu 14.10 as standalone with service disabled' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '14.10',
:path => '/usr/local/bin:/usr/bin:/bin', } }
let(:params) { { :inetd => false, :ensure => 'stopped', :enable => false, } }
it {
should contain_package('tftpd-hpa')
should contain_file('/etc/default/tftpd-hpa')
should contain_service('tftpd-hpa').with({
'ensure' => 'stopped',
'enable' => false,
'hasstatus' => true,
'provider' => 'upstart',
})
}
end

describe 'when deploying on ubuntu 15.04 or greater as standalone with default params' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '15.04',
Expand All @@ -72,7 +129,25 @@
}
end

describe 'when deploying on ubuntu 16.04 or greater as standalone' do
describe 'when deploying on ubuntu 15.04 or greater as standalone with service disabled' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '15.04',
:path => '/usr/local/bin:/usr/bin:/bin', } }
let(:params) { { :inetd => false, :ensure => 'stopped', :enable => false, } }
it {
should contain_package('tftpd-hpa')
should contain_file('/etc/default/tftpd-hpa')
should contain_service('tftpd-hpa').with({
'ensure' => 'stopped',
'enable' => false,
'hasstatus' => true,
'provider' => 'systemd',
})
}
end

describe 'when deploying on ubuntu 16.04 or greater as standalone with default params' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '16.04',
Expand All @@ -90,6 +165,24 @@
}
end

describe 'when deploying on ubuntu 16.04 or greater as standalone with service disabled' do
let(:facts) { { :operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:operatingsystemrelease => '16.04',
:path => '/usr/local/bin:/usr/bin:/bin', } }
let(:params) { { :inetd => false, :ensure => 'stopped', :enable => false, } }
it {
should contain_package('tftpd-hpa')
should contain_file('/etc/default/tftpd-hpa')
should contain_service('tftpd-hpa').with({
'ensure' => 'stopped',
'enable' => false,
'hasstatus' => true,
'provider' => 'systemd',
})
}
end

describe 'when deploying on redhat family as standalone' do
let (:facts) { { :osfamily => 'RedHat',
:path => '/usr/local/bin:/usr/bin:/bin', } }
Expand All @@ -109,6 +202,25 @@
}
end

describe 'when deploying on redhat family as standalone with service disabled' do
let (:facts) { { :osfamily => 'RedHat',
:path => '/usr/local/bin:/usr/bin:/bin', } }
let(:params) { { :inetd => false, :ensure => 'stopped', :enable => false, } }
it {
should contain_package('tftpd-hpa').with({
'name' => 'tftp-server',
})

should contain_service('tftpd-hpa').with({
'ensure' => 'stopped',
'enable' => 'false',
'hasstatus' => false,
'provider' => 'base',
'start' => '/usr/sbin/in.tftpd -l -a 0.0.0.0:69 -u nobody --secure /var/lib/tftpboot',
})
}
end

describe 'when deploying on redhat family with custom options as standalone' do
let (:facts) { { :osfamily => 'RedHat',
:path => '/usr/local/bin:/usr/bin:/bin', } }
Expand Down