From 408f02ba9cb24804a09462ce5448c49bf1c0c8ca Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 12:51:23 -0700 Subject: Add EL (RHEL/CentOS) support for tftp. * EL tftpd-hpa package is called tftp-server * Distributed RPM doesn't provide an init file so the base provider is needed * Default username for tftp-server on RHEL is nobody * no /etc/default/tftpd-hpa should be pushed for EL systems --- manifests/init.pp | 34 ++++++++++++++++++++++----------- manifests/params.pp | 54 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 26 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9dfab37..5057eb2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,19 +31,26 @@ class tftp ( $port = $tftp::params::port, $options = $tftp::params::options, $inetd = false, - $inetd_conf = $tftp::params::inetd_conf + $inetd_conf = $tftp::params::inetd_conf, + $package = $tftp::params::package, + $binary = $tftp::params::binary, + $defaults = $tftp::params::defaults ) inherits tftp::params { + package { 'tftpd-hpa': - ensure => present, + ensure => present, + name => $package, } - - file { '/etc/default/tftpd-hpa': - ensure => file, - owner => 'root', - group => 'root', - mode => '0644', - content => template('tftp/tftpd-hpa.erb'), - require => Package['tftpd-hpa'], + if $defaults { + file { '/etc/default/tftpd-hpa': + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + content => template('tftp/tftpd-hpa.erb'), + require => Package['tftpd-hpa'], + notify => Service['tftpd-hpa'], + } } if $inetd { @@ -77,12 +84,17 @@ class tftp ( $svc_enable = true } + $start = $binary ? { + undef => undef, + default => "${binary} -l -a ${address}:${port} -u ${username} ${options} ${directory}" + } + service { 'tftpd-hpa': ensure => $svc_ensure, enable => $svc_enable, provider => $tftp::params::provider, hasstatus => $tftp::params::hasstatus, pattern => '/usr/sbin/in.tftpd', - subscribe => File['/etc/default/tftpd-hpa'], + start => $start, } } diff --git a/manifests/params.pp b/manifests/params.pp index e658184..b688dd5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,28 +4,52 @@ class tftp::params { $address = '0.0.0.0' $port = '69' - $username = 'tftp' $options = '--secure' $inetd_conf = '/etc/inetd.conf' - case $::operatingsystem { + case $::osfamily { 'debian': { - # hasstatus is to get around an issue where the service script appears to - # be broken. - $directory = '/srv/tftp' - $hasstatus = false - $provider = undef + $package = 'tftpd-hpa' + $defaults = true + $binary = undef + $username = 'tftp' + case $::operatingsystem { + 'debian': { + $directory = '/srv/tftp' + $hasstatus = false + $provider = undef + } + 'ubuntu': { + $directory = '/var/lib/tftpboot' + $hasstatus = true + $provider = 'upstart' + } + default: { + $directory = '/var/lib/tftpboot' + $hasstatus = true + $provider = undef + warning("tftp:: cannot determine settings for $::operatingsystem") + } + } } - 'ubuntu': { - $directory = '/var/lib/tftpboot' - $hasstatus = true - $provider = 'upstart' + 'redhat': { + $package = 'tftp-server' + $username = 'nobody' + $defaults = false + $directory = '/var/lib/tftpboot' + $hasstatus = false + $provider = 'base' + $binary = '/usr/sbin/in.tftpd' } default: { - warning("tftp:: not verified on operatingsystem ${::operatingsystem}.") - $directory = '/var/lib/tftpboot' - $hasstatus = true - $provider = undef + $package = 'tftpd' + $username = 'nobody' + $defaults = false + $hasstatus = false + $provider = undef + $binary = '/usr/sbin/in.tftpd' + warning("tftp:: $::operatingsystem may not be supported") } } + } -- cgit v1.2.3 From c3d0b8b46f1cf9ed1b00660bacd1ebbcd96800da Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 14:27:10 -0700 Subject: Removing dependancy on 'inetd' which doesn't exist in the forge... Replaced with xinetd::service to set up the xinetd configuration --- manifests/init.pp | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5057eb2..df9dbc2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -58,25 +58,21 @@ class tftp ( fail('tftp class does not support custom options when inetd is enabled.') } - include 'inetd' - - augeas { 'inetd_tftp': - changes => [ - "ins tftp after /files${inetd_conf}", - "set /files${inetd_conf}/tftp/socket dgram", - "set /files${inetd_conf}/tftp/protocol udp", - "set /files${inetd_conf}/tftp/wait wait", - "set /files${inetd_conf}/tftp/user ${username}", - "set /files${inetd_conf}/tftp/command /usr/libexec/tftpd", - "set /files${inetd_conf}/tftp/arguments/1 tftpd", - "set /files${inetd_conf}/tftp/arguments/2 --address", - "set /files${inetd_conf}/tftp/arguments/3 ${address}:${port}", - "set /files${inetd_conf}/tftp/arguments/4 --secure", - "set /files${inetd_conf}/tftp/arguments/5 ${directory}", - ], - require => Class['inetd'], - } + include 'xinetd' + xinetd::service { 'tftp': + port => $port, + protocol => 'udp', + server_args => "${options} ${directory}", + server => $binary, + user => $username, + bind => $address, + socket_type => 'dgram', + cps => '100 2', + flags => 'IPv4', + per_source => '11', + wait => 'yes', + } $svc_ensure = stopped $svc_enable = false } else { @@ -84,9 +80,9 @@ class tftp ( $svc_enable = true } - $start = $binary ? { - undef => undef, - default => "${binary} -l -a ${address}:${port} -u ${username} ${options} ${directory}" + $start = $provider ? { + 'base' => "${binary} -l -a ${address}:${port} -u ${username} ${options} ${directory}", + default => undef } service { 'tftpd-hpa': -- cgit v1.2.3 From d418a40a91b6493a0659e8739587a79786735b3c Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 14:28:08 -0700 Subject: According to the man pages and examples I've seen there is no reason why server_args can't be used to pass in extra options to in.tftpd If this is not the case, please let me know. --- manifests/init.pp | 3 --- 1 file changed, 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index df9dbc2..76ed7c9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,9 +54,6 @@ class tftp ( } if $inetd { - if $options != '--secure' { - fail('tftp class does not support custom options when inetd is enabled.') - } include 'xinetd' -- cgit v1.2.3 From 57e69bf36be91ae3e95a2ab5af259029ea54ece7 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 14:31:42 -0700 Subject: No need to set binary to undef for debian now we evaluate the provider variable instead. --- manifests/params.pp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index b688dd5..e5de774 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,12 +6,12 @@ class tftp::params { $port = '69' $options = '--secure' $inetd_conf = '/etc/inetd.conf' + $binary = '/usr/sbin/in.tftpd' case $::osfamily { 'debian': { $package = 'tftpd-hpa' $defaults = true - $binary = undef $username = 'tftp' case $::operatingsystem { 'debian': { @@ -39,7 +39,6 @@ class tftp::params { $directory = '/var/lib/tftpboot' $hasstatus = false $provider = 'base' - $binary = '/usr/sbin/in.tftpd' } default: { $package = 'tftpd' @@ -47,7 +46,6 @@ class tftp::params { $defaults = false $hasstatus = false $provider = undef - $binary = '/usr/sbin/in.tftpd' warning("tftp:: $::operatingsystem may not be supported") } } -- cgit v1.2.3 From 6ecee7dd83b51f6a25f98ff1600410a1bb531410 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 16:41:06 -0700 Subject: Updated rspec tests for new functionality * Removed rspec-tests for inetd * Modified existing tests to work with new evaluation of :osfamily * Added tests for Redhat/CentOS boxes * Added rspec-tests for xinetd service --- spec/classes/tftp_spec.rb | 190 +++++++++++++++++++++++++++++++++-------- spec/defines/tftp_file_spec.rb | 8 ++ 2 files changed, 164 insertions(+), 34 deletions(-) diff --git a/spec/classes/tftp_spec.rb b/spec/classes/tftp_spec.rb index 016130d..055f1b5 100644 --- a/spec/classes/tftp_spec.rb +++ b/spec/classes/tftp_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' describe 'tftp', :type => :class do describe 'when deploying on debian' do - let(:facts) { { :operatingsystem => 'Debian', - :path => '/usr/local/bin:/usr/bin:/bin', } } + let(:facts) { { :operatingsystem => 'Debian', + :osfamily => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', } } it { should contain_file('/etc/default/tftpd-hpa') } it { should contain_package('tftpd-hpa') } @@ -16,8 +17,9 @@ describe 'tftp', :type => :class do end describe 'when deploying on ubuntu' do - let(:facts) { { :operatingsystem => 'Ubuntu', - :path => '/usr/local/bin:/usr/bin:/bin', } } + let(:facts) { { :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', } } it { should contain_package('tftpd-hpa') } it { should contain_file('/etc/default/tftpd-hpa') } @@ -29,43 +31,163 @@ describe 'tftp', :type => :class do }) } end - describe 'when deploying with inetd' do - let(:facts) { { :operatingsystem => 'Debian', - :path => '/usr/local/bin:/usr/bin:/bin', } } - let(:params) { { :inetd => true, } } + describe 'when deploying on redhat family' do + let (:facts) { { :osfamily => 'RedHat', + :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should contain_package('tftpd-hpa') } - it { should contain_file('/etc/default/tftpd-hpa') } - it { should contain_class('inetd') } - it { should contain_augeas('inetd_tftp').with({ - 'changes' => [ - "ins tftp after /files/etc/inetd.conf", - "set /files/etc/inetd.conf/tftp/socket dgram", - "set /files/etc/inetd.conf/tftp/protocol udp", - "set /files/etc/inetd.conf/tftp/wait wait", - "set /files/etc/inetd.conf/tftp/user tftp", - "set /files/etc/inetd.conf/tftp/command /usr/libexec/tftpd", - "set /files/etc/inetd.conf/tftp/arguments/1 tftpd", - "set /files/etc/inetd.conf/tftp/arguments/2 --address", - "set /files/etc/inetd.conf/tftp/arguments/3 0.0.0.0:69", - "set /files/etc/inetd.conf/tftp/arguments/4 --secure", - "set /files/etc/inetd.conf/tftp/arguments/5 /srv/tftp", - ], + it { should contain_package('tftpd-hpa').with({ + 'name' => 'tftp-server', }) } + it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'stopped', - 'enable' => false, + 'ensure' => 'running', + 'enable' => 'true', 'hasstatus' => false, - 'provider' => nil, + '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' do + let (:facts) { { :osfamily => 'RedHat', + :path => '/usr/local/bin:/usr/bin:/bin', } } + let (:params) { { :address => '127.0.0.1', + :port => '1069', + :username => 'root', + :options => '--secure --timeout 50', + :directory => '/tftpboot', } } + + it { should contain_package('tftpd-hpa').with({ + 'name' => 'tftp-server', + }) } + + it { should contain_service('tftpd-hpa').with({ + 'ensure' => 'running', + 'enable' => 'true', + 'hasstatus' => false, + 'provider' => 'base', + 'start' => '/usr/sbin/in.tftpd -l -a 127.0.0.1:1069 -u root --secure --timeout 50 /tftpboot', }) } end - describe 'when deploying with inetd and custom options' do - let(:facts) { { :operatingsystem => 'Debian', - :path => '/usr/local/bin:/usr/bin:/bin', } } - let(:params) { { :inetd => true, - :options => '--timeout 5 --secure', } } + describe 'when deploying with xinetd on redhat family' do + let (:facts) { { :osfamily => 'Redhat', + :path => '/usr/local/bin:/usr/bin:/bin', } } + let (:params) { { :inetd => true, } } + it { should include_class('xinetd') } + it { should contain_service('tftpd-hpa').with({ + 'ensure' => 'stopped', + 'enable' => false, + }) } + it { should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure /var/lib/tftpboot', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'nobody', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + }) } - it { expect { should contain_class('tftp') }.to raise_error(Puppet::Error) } end + + describe 'when deploying with xinetd on ubuntu' do + let (:facts) { { :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :path => '/usr/local/bin:/usr/bin:/bin', } } + let (:params) { { :inetd => true, } } + it { should include_class('xinetd') } + it { should contain_service('tftpd-hpa').with({ + 'ensure' => 'stopped', + 'enable' => false, + }) } + it { should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure /var/lib/tftpboot', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'tftp', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + }) } + + end + + describe 'when deploying with xinetd on debian' do + let (:facts) { { :osfamily => 'Debian', + :operatingsystem => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', } } + let (:params) { { :inetd => true, } } + it { should include_class('xinetd') } + it { should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure /srv/tftp', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'tftp', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + 'bind' => '0.0.0.0', + }) } + + end + + describe 'when deploying with xinetd with custom options' do + let (:facts) { { :osfamily => 'Debian', + :operatingsystem => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', } } + let (:params) { { :inetd => true, + :options => '--secure --timeout 50', } } + it { should include_class('xinetd') } + it { should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure --timeout 50 /srv/tftp', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'tftp', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + 'bind' => '0.0.0.0', + }) } + + end + + describe 'when deploying with xinetd with custom settings' do + let (:facts) { { :osfamily => 'Debian', + :operatingsystem => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', } } + let (:params) { { :inetd => true, + :port => 1069, + :address => '127.0.0.1', + :username => 'root', + :directory => '/tftpboot', } } + it { should include_class('xinetd') } + it { should contain_xinetd__service('tftp').with({ + 'port' => '1069', + 'protocol' => 'udp', + 'server_args' => '--secure /tftpboot', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'root', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + 'bind' => '127.0.0.1', + }) } + + end + end diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb index 0de1b6f..84c9e33 100644 --- a/spec/defines/tftp_file_spec.rb +++ b/spec/defines/tftp_file_spec.rb @@ -6,6 +6,7 @@ describe 'tftp::file' do describe 'when deploying on debian' do let(:facts) { { :operatingsystem => 'Debian', + :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } it { should include_class('tftp') } @@ -20,6 +21,7 @@ describe 'tftp::file' do describe 'when deploying on ubuntu' do let(:facts) { { :operatingsystem => 'ubuntu', + :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } it { should include_class('tftp') } @@ -39,6 +41,7 @@ describe 'tftp::file' do :mode => '0755', :recurse => true }} let(:facts) { { :operatingsystem => 'Debian', + :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } it { should include_class('tftp') } @@ -53,6 +56,7 @@ describe 'tftp::file' do describe 'when deploying without recurse parameters' do let(:facts) { {:operatingsystem => 'Debian', + :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } it { should include_class('tftp') } @@ -73,6 +77,7 @@ describe 'tftp::file' do :purge => true, :replace => false }} let(:facts) { {:operatingsystem => 'Debian', + :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', }} it { should include_class('tftp') } @@ -92,6 +97,7 @@ describe 'tftp::file' do let(:params) { {:ensure => 'directory', :mode => '0755' }} let(:facts) { { :operatingsystem => 'Debian', + :osfamily => 'Debian', :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } @@ -107,6 +113,7 @@ describe 'tftp::file' do let(:params) { {:ensure => 'file', :mode => '0755' }} let(:facts) { { :operatingsystem => 'Debian', + :osfamily => 'Debian', :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } @@ -123,6 +130,7 @@ describe 'tftp::file' do :content => 'hi', :mode => '0755' }} let(:facts) { { :operatingsystem => 'Debian', + :osfamily => 'Debian', :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } -- cgit v1.2.3 From 0e60a3f8006c406c7db4c23f19a4d24a57603ef3 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 16:48:50 -0700 Subject: * remove old references to inetd_conf --- manifests/init.pp | 6 ++---- manifests/params.pp | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 76ed7c9..973049c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,14 +7,13 @@ # [*address*]: tftp service bind address (default 0.0.0.0). # [*port*]: tftp service bind port (default 69). # [*options*]: tftp service bind port (default 69). -# [*inetd*]: tftp service bind port (default 69). -# [*inetd_conf*]: tftp service bind port (default 69). +# [*inetd*]: Run as an xinetd service instead of standalone daemon (false) # # Actions: # # Requires: # -# puppetlabs-inetd when inetd = true. +# Class['xinetd'] (if inetd set to true) # # Usage: # @@ -31,7 +30,6 @@ class tftp ( $port = $tftp::params::port, $options = $tftp::params::options, $inetd = false, - $inetd_conf = $tftp::params::inetd_conf, $package = $tftp::params::package, $binary = $tftp::params::binary, $defaults = $tftp::params::defaults diff --git a/manifests/params.pp b/manifests/params.pp index e5de774..288f0b0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,6 @@ class tftp::params { $address = '0.0.0.0' $port = '69' $options = '--secure' - $inetd_conf = '/etc/inetd.conf' $binary = '/usr/sbin/in.tftpd' case $::osfamily { -- cgit v1.2.3 From cc0bee63f66091cdd724b0b96a54d7408f2a3a8d Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 16:51:52 -0700 Subject: Tweaked documentation to add Redhat and show inet changes --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d1c41c7..996f889 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Overview -Install tftp-hpa package and configuration files for osfamily Debian. +Install tftp-hpa package and configuration files ## Usage @@ -10,15 +10,12 @@ Install tftp-hpa package and configuration files for osfamily Debian. Parameters: -* username: tftp daemon user, default tftp. +* username: tftp daemon user, default tftp(debian) or nobody(redhat). * directory: service directory, deafult see params class. * address: bind address, default 0.0.0.0. * port: bind port, default 69. * options: service option, default --secure. -* inetd: run service via inetd, default false. (Warning: this option when enabled to true is not compatible with custom service options). -* inetd_conf: inetd.conf file path, default /etc/inetd.conf. - -Enabling inetd requires [puppetlabs-inetd](https://github.com/puppetlabs/puppetlabs-inetd) module. +* inetd: run service via xinetd - default false. Example: @@ -90,3 +87,4 @@ The module have been tested on the following operating systems. Testing and patc * Debian Wheezy * Ubuntu Oneiric +* CentOS -- cgit v1.2.3 From ce162ee814bfe2e98d845118e9e3fbcef8817abf Mon Sep 17 00:00:00 2001 From: crayfishx Date: Tue, 10 Jul 2012 16:59:30 -0700 Subject: Bumped version to 0.2.0 and added dependancy to puppetlabs-xinetd --- CHANGELOG | 5 +++++ Modulefile | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 514f006..b980250 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +0.2.0 2012-07-10 Puppet Labs + +* Add support for Redhat/CentOS deployment +* Replacement of inetd and augeas config with puppetlabs-xinetd + 0.1.1 2012-06-25 Puppet Labs * Add recurse support for tftp::file. diff --git a/Modulefile b/Modulefile index 950110f..a5b0fb8 100644 --- a/Modulefile +++ b/Modulefile @@ -1,11 +1,11 @@ name 'puppetlabs-tftp' -version '0.1.1' +version '0.2.0' source 'git://github.com/puppetlabs/puppetlabs-tftp' author 'Puppet Labs' license 'Apache 2.0' summary 'Puppet Labs TFTP Module' -description 'Manage tftp service and files for Debian/Ubuntu.' +description 'Manage tftp service and files for Debian/Ubuntu/CentOS/Redhat/Fedora.' project_page 'https://github.com/puppetlabs/puppetlabs-tftp' ## Add dependencies, if any: -# dependency 'username/name', '>= 1.2.0' +dependency 'puppetlabs/xinetd', '>= 1.1.0' -- cgit v1.2.3 From d5cc38649f298811127590323ec2f31c9df01da9 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 09:41:43 -0700 Subject: Removed unneeded default This default isn't needed while debian and ubuntu are the only things in osfamily Debian. --- manifests/params.pp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 288f0b0..3520068 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,12 +23,6 @@ class tftp::params { $hasstatus = true $provider = 'upstart' } - default: { - $directory = '/var/lib/tftpboot' - $hasstatus = true - $provider = undef - warning("tftp:: cannot determine settings for $::operatingsystem") - } } } 'redhat': { -- cgit v1.2.3 From cb8c935a010fe0935d08a73b0ca2aa91a328943e Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 10:30:36 -0700 Subject: Single it block per test * as originally submitted in https://github.com/puppetlabs/puppetlabs-tftp/pull/10... * Only use one it block per test to improve performance --- spec/classes/tftp_spec.rb | 251 ++++++++++++++++++++++------------------- spec/defines/tftp_file_spec.rb | 141 +++++++++++++---------- 2 files changed, 211 insertions(+), 181 deletions(-) diff --git a/spec/classes/tftp_spec.rb b/spec/classes/tftp_spec.rb index 055f1b5..21e6f72 100644 --- a/spec/classes/tftp_spec.rb +++ b/spec/classes/tftp_spec.rb @@ -6,14 +6,16 @@ describe 'tftp', :type => :class do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should contain_file('/etc/default/tftpd-hpa') } - it { should contain_package('tftpd-hpa') } - it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'running', - 'enable' => true, - 'hasstatus' => false, - 'provider' => nil, - }) } + it { + should contain_file('/etc/default/tftpd-hpa') + should contain_package('tftpd-hpa') + should contain_service('tftpd-hpa').with({ + 'ensure' => 'running', + 'enable' => true, + 'hasstatus' => false, + 'provider' => nil, + }) + } end describe 'when deploying on ubuntu' do @@ -21,31 +23,35 @@ describe 'tftp', :type => :class do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should contain_package('tftpd-hpa') } - it { should contain_file('/etc/default/tftpd-hpa') } - it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'running', - 'enable' => true, - 'hasstatus' => true, - 'provider' => 'upstart', - }) } + it { + should contain_package('tftpd-hpa') + should contain_file('/etc/default/tftpd-hpa') + should contain_service('tftpd-hpa').with({ + 'ensure' => 'running', + 'enable' => true, + 'hasstatus' => true, + 'provider' => 'upstart', + }) + } end describe 'when deploying on redhat family' do let (:facts) { { :osfamily => 'RedHat', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should contain_package('tftpd-hpa').with({ - 'name' => 'tftp-server', - }) } - - it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'running', - 'enable' => 'true', - 'hasstatus' => false, - 'provider' => 'base', - 'start' => '/usr/sbin/in.tftpd -l -a 0.0.0.0:69 -u nobody --secure /var/lib/tftpboot', - }) } + it { + should contain_package('tftpd-hpa').with({ + 'name' => 'tftp-server', + }) + + should contain_service('tftpd-hpa').with({ + 'ensure' => 'running', + 'enable' => 'true', + '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' do @@ -57,41 +63,44 @@ describe 'tftp', :type => :class do :options => '--secure --timeout 50', :directory => '/tftpboot', } } - it { should contain_package('tftpd-hpa').with({ - 'name' => 'tftp-server', - }) } - - it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'running', - 'enable' => 'true', - 'hasstatus' => false, - 'provider' => 'base', - 'start' => '/usr/sbin/in.tftpd -l -a 127.0.0.1:1069 -u root --secure --timeout 50 /tftpboot', - }) } + it { + should contain_package('tftpd-hpa').with({ + 'name' => 'tftp-server', + }) + + should contain_service('tftpd-hpa').with({ + 'ensure' => 'running', + 'enable' => 'true', + 'hasstatus' => false, + 'provider' => 'base', + 'start' => '/usr/sbin/in.tftpd -l -a 127.0.0.1:1069 -u root --secure --timeout 50 /tftpboot', + }) + } end describe 'when deploying with xinetd on redhat family' do let (:facts) { { :osfamily => 'Redhat', :path => '/usr/local/bin:/usr/bin:/bin', } } let (:params) { { :inetd => true, } } - it { should include_class('xinetd') } - it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'stopped', - 'enable' => false, - }) } - it { should contain_xinetd__service('tftp').with({ - 'port' => '69', - 'protocol' => 'udp', - 'server_args' => '--secure /var/lib/tftpboot', - 'server' => '/usr/sbin/in.tftpd', - 'user' => 'nobody', - 'socket_type' => 'dgram', - 'cps' => '100 2', - 'flags' => 'IPv4', - 'per_source' => '11', - 'wait' => 'yes', - }) } - + it { + should include_class('xinetd') + should contain_service('tftpd-hpa').with({ + 'ensure' => 'stopped', + 'enable' => false, + }) + should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure /var/lib/tftpboot', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'nobody', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + }) + } end describe 'when deploying with xinetd on ubuntu' do @@ -99,24 +108,25 @@ describe 'tftp', :type => :class do :operatingsystem => 'Ubuntu', :path => '/usr/local/bin:/usr/bin:/bin', } } let (:params) { { :inetd => true, } } - it { should include_class('xinetd') } - it { should contain_service('tftpd-hpa').with({ - 'ensure' => 'stopped', - 'enable' => false, - }) } - it { should contain_xinetd__service('tftp').with({ - 'port' => '69', - 'protocol' => 'udp', - 'server_args' => '--secure /var/lib/tftpboot', - 'server' => '/usr/sbin/in.tftpd', - 'user' => 'tftp', - 'socket_type' => 'dgram', - 'cps' => '100 2', - 'flags' => 'IPv4', - 'per_source' => '11', - 'wait' => 'yes', - }) } - + it { + should include_class('xinetd') + should contain_service('tftpd-hpa').with({ + 'ensure' => 'stopped', + 'enable' => false, + }) + should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure /var/lib/tftpboot', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'tftp', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + }) + } end describe 'when deploying with xinetd on debian' do @@ -124,21 +134,22 @@ describe 'tftp', :type => :class do :operatingsystem => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } let (:params) { { :inetd => true, } } - it { should include_class('xinetd') } - it { should contain_xinetd__service('tftp').with({ - 'port' => '69', - 'protocol' => 'udp', - 'server_args' => '--secure /srv/tftp', - 'server' => '/usr/sbin/in.tftpd', - 'user' => 'tftp', - 'socket_type' => 'dgram', - 'cps' => '100 2', - 'flags' => 'IPv4', - 'per_source' => '11', - 'wait' => 'yes', - 'bind' => '0.0.0.0', - }) } - + it { + should include_class('xinetd') + should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure /srv/tftp', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'tftp', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + 'bind' => '0.0.0.0', + }) + } end describe 'when deploying with xinetd with custom options' do @@ -147,21 +158,22 @@ describe 'tftp', :type => :class do :path => '/usr/local/bin:/usr/bin:/bin', } } let (:params) { { :inetd => true, :options => '--secure --timeout 50', } } - it { should include_class('xinetd') } - it { should contain_xinetd__service('tftp').with({ - 'port' => '69', - 'protocol' => 'udp', - 'server_args' => '--secure --timeout 50 /srv/tftp', - 'server' => '/usr/sbin/in.tftpd', - 'user' => 'tftp', - 'socket_type' => 'dgram', - 'cps' => '100 2', - 'flags' => 'IPv4', - 'per_source' => '11', - 'wait' => 'yes', - 'bind' => '0.0.0.0', - }) } - + it { + should include_class('xinetd') + should contain_xinetd__service('tftp').with({ + 'port' => '69', + 'protocol' => 'udp', + 'server_args' => '--secure --timeout 50 /srv/tftp', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'tftp', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + 'bind' => '0.0.0.0', + }) + } end describe 'when deploying with xinetd with custom settings' do @@ -173,21 +185,22 @@ describe 'tftp', :type => :class do :address => '127.0.0.1', :username => 'root', :directory => '/tftpboot', } } - it { should include_class('xinetd') } - it { should contain_xinetd__service('tftp').with({ - 'port' => '1069', - 'protocol' => 'udp', - 'server_args' => '--secure /tftpboot', - 'server' => '/usr/sbin/in.tftpd', - 'user' => 'root', - 'socket_type' => 'dgram', - 'cps' => '100 2', - 'flags' => 'IPv4', - 'per_source' => '11', - 'wait' => 'yes', - 'bind' => '127.0.0.1', - }) } - + it { + should include_class('xinetd') + should contain_xinetd__service('tftp').with({ + 'port' => '1069', + 'protocol' => 'udp', + 'server_args' => '--secure /tftpboot', + 'server' => '/usr/sbin/in.tftpd', + 'user' => 'root', + 'socket_type' => 'dgram', + 'cps' => '100 2', + 'flags' => 'IPv4', + 'per_source' => '11', + 'wait' => 'yes', + 'bind' => '127.0.0.1', + }) + } end end diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb index 84c9e33..1ad62d8 100644 --- a/spec/defines/tftp_file_spec.rb +++ b/spec/defines/tftp_file_spec.rb @@ -9,14 +9,16 @@ describe 'tftp::file' do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'file', - 'owner' => 'tftp', - 'group' => 'tftp', - 'mode' => '0644', - 'recurse' => false, - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'file', + 'owner' => 'tftp', + 'group' => 'tftp', + 'mode' => '0644', + 'recurse' => false, + }) + } end describe 'when deploying on ubuntu' do @@ -24,14 +26,16 @@ describe 'tftp::file' do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/var/lib/tftpboot/sample').with({ - 'ensure' => 'file', - 'owner' => 'tftp', - 'group' => 'tftp', - 'mode' => '0644', - 'recurse' => false, - }) } + it { + should include_class('tftp') + should contain_file('/var/lib/tftpboot/sample').with({ + 'ensure' => 'file', + 'owner' => 'tftp', + 'group' => 'tftp', + 'mode' => '0644', + 'recurse' => false, + }) + } end describe 'when deploying with parameters' do @@ -44,14 +48,16 @@ describe 'tftp::file' do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'directory', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0755', - 'recurse' => true, - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'directory', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0755', + 'recurse' => true, + }) + } end describe 'when deploying without recurse parameters' do @@ -59,14 +65,16 @@ describe 'tftp::file' do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'file', - 'recurse' => false, - 'purge' => nil, - 'replace' => nil, - 'recurselimit' => nil, - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'file', + 'recurse' => false, + 'purge' => nil, + 'replace' => nil, + 'recurselimit' => nil, + }) + } end describe 'when deploying with recurse parameters' do @@ -80,17 +88,19 @@ describe 'tftp::file' do :osfamily => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', }} - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'directory', - 'owner' => 'tftp', - 'group' => 'tftp', - 'mode' => '0755', - 'recurse' => true, - 'recurselimit' => 42, - 'purge' => true, - 'replace' => false, - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'directory', + 'owner' => 'tftp', + 'group' => 'tftp', + 'mode' => '0755', + 'recurse' => true, + 'recurselimit' => 42, + 'purge' => true, + 'replace' => false, + }) + } end describe 'when deploying directory' do @@ -101,12 +111,14 @@ describe 'tftp::file' do :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'directory', - 'mode' => '0755', - 'source' => nil, - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'directory', + 'mode' => '0755', + 'source' => nil, + }) + } end describe 'when deploying file from another module' do @@ -117,12 +129,14 @@ describe 'tftp::file' do :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'file', - 'mode' => '0755', - 'source' => 'puppet:///modules/acme/sample' - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'file', + 'mode' => '0755', + 'source' => 'puppet:///modules/acme/sample' + }) + } end describe 'when deploying file with content' do @@ -134,12 +148,15 @@ describe 'tftp::file' do :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') } - it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'file', - 'mode' => '0755', - 'content' => 'hi', - 'source' => nil, - }) } + it { + should include_class('tftp') + should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'file', + 'mode' => '0755', + 'content' => 'hi', + 'source' => nil, + }) + } end + end -- cgit v1.2.3 From 95de79b4c707ffd5bf9e4bee24ad96ce1e8e3285 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 10:39:18 -0700 Subject: Revert "Bumped version to 0.2.0 and added dependancy to puppetlabs-xinetd" This reverts commit ce162ee814bfe2e98d845118e9e3fbcef8817abf. --- CHANGELOG | 5 ----- Modulefile | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b980250..514f006 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,3 @@ -0.2.0 2012-07-10 Puppet Labs - -* Add support for Redhat/CentOS deployment -* Replacement of inetd and augeas config with puppetlabs-xinetd - 0.1.1 2012-06-25 Puppet Labs * Add recurse support for tftp::file. diff --git a/Modulefile b/Modulefile index a5b0fb8..950110f 100644 --- a/Modulefile +++ b/Modulefile @@ -1,11 +1,11 @@ name 'puppetlabs-tftp' -version '0.2.0' +version '0.1.1' source 'git://github.com/puppetlabs/puppetlabs-tftp' author 'Puppet Labs' license 'Apache 2.0' summary 'Puppet Labs TFTP Module' -description 'Manage tftp service and files for Debian/Ubuntu/CentOS/Redhat/Fedora.' +description 'Manage tftp service and files for Debian/Ubuntu.' project_page 'https://github.com/puppetlabs/puppetlabs-tftp' ## Add dependencies, if any: -dependency 'puppetlabs/xinetd', '>= 1.1.0' +# dependency 'username/name', '>= 1.2.0' -- cgit v1.2.3 From 2c4423a83a96215de6746873069f40f279e887ff Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 10:40:49 -0700 Subject: Added module dependancy to puppetlabs-xinetd --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 950110f..b89b9b8 100644 --- a/Modulefile +++ b/Modulefile @@ -8,4 +8,4 @@ description 'Manage tftp service and files for Debian/Ubuntu.' project_page 'https://github.com/puppetlabs/puppetlabs-tftp' ## Add dependencies, if any: -# dependency 'username/name', '>= 1.2.0' +dependency 'puppetlabs/xinetd', '>= 1.1.0' -- cgit v1.2.3 From b5fce3cce34c5ff01243a4dfe9205d26f3c98857 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 10:51:18 -0700 Subject: Fully qualify $::caller_module_name fact. This fixes the following failed test: 1) tftp::file when deploying file from another module Failure/Error: }) expected that the catalogue would contain File[/srv/tftp/sample] with source set to `"puppet:///modules/acme/sample"` but it is set to `"puppet:///modules/tftp/sample"` in the catalogue # ./spec/defines/tftp_file_spec.rb:138 --- manifests/file.pp | 4 ++-- spec/fixtures/manifests/site.pp | 0 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 spec/fixtures/manifests/site.pp diff --git a/manifests/file.pp b/manifests/file.pp index 3628188..6eaa394 100644 --- a/manifests/file.pp +++ b/manifests/file.pp @@ -44,8 +44,8 @@ define tftp::file ( if $source { $source_real = $source } elsif $ensure != 'directory' and ! $content { - if $caller_module_name { - $mod = $caller_module_name + if $::caller_module_name { + $mod = $::caller_module_name } else { $mod = $module_name } diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3 From a60b40eb9f2e612f913aa14087632eac088f6e50 Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 11:51:39 -0700 Subject: Revert "Fully qualify $::caller_module_name fact." * the problem is with the test not the code This reverts commit b5fce3cce34c5ff01243a4dfe9205d26f3c98857. --- manifests/file.pp | 4 ++-- spec/fixtures/manifests/site.pp | 0 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/manifests/site.pp diff --git a/manifests/file.pp b/manifests/file.pp index 6eaa394..3628188 100644 --- a/manifests/file.pp +++ b/manifests/file.pp @@ -44,8 +44,8 @@ define tftp::file ( if $source { $source_real = $source } elsif $ensure != 'directory' and ! $content { - if $::caller_module_name { - $mod = $::caller_module_name + if $caller_module_name { + $mod = $caller_module_name } else { $mod = $module_name } diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From 07062af1a236646970906d4a3f98f1646fcca44d Mon Sep 17 00:00:00 2001 From: crayfishx Date: Wed, 11 Jul 2012 12:11:40 -0700 Subject: Changed rspec test for calling outside of module Until we decide how to simulate rspec-puppet calling this class from a different module this test has been changed to just test deploying the file. --- spec/defines/tftp_file_spec.rb | 6 ++---- spec/fixtures/manifests/site.pp | 0 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 spec/fixtures/manifests/site.pp diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb index 1ad62d8..e24f0f3 100644 --- a/spec/defines/tftp_file_spec.rb +++ b/spec/defines/tftp_file_spec.rb @@ -121,12 +121,11 @@ describe 'tftp::file' do } end - describe 'when deploying file from another module' do + describe 'when deploying file' do let(:params) { {:ensure => 'file', :mode => '0755' }} let(:facts) { { :operatingsystem => 'Debian', :osfamily => 'Debian', - :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } it { @@ -134,7 +133,7 @@ describe 'tftp::file' do should contain_file('/srv/tftp/sample').with({ 'ensure' => 'file', 'mode' => '0755', - 'source' => 'puppet:///modules/acme/sample' + 'source' => 'puppet:///modules/tftp/sample' }) } end @@ -147,7 +146,6 @@ describe 'tftp::file' do :osfamily => 'Debian', :caller_module_name => 'acme', :path => '/usr/local/bin:/usr/bin:/bin', } } - it { should include_class('tftp') should contain_file('/srv/tftp/sample').with({ diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3