aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNan Liu <nan.liu@gmail.com>2012-06-25 12:03:46 -0700
committerNan Liu <nan.liu@gmail.com>2012-06-25 12:03:46 -0700
commit6500ac722b939b86c32559508be3c7f224ba5cfe (patch)
treeb701820e75b268d86a2800b33654e26fb304fcae
parent5b360e17be617ef8e5b3722de7578642bd881b76 (diff)
parent2c22a9b5fd0336681a4fca9d8f875b15950fdacb (diff)
downloadpuppet-tftp-6500ac722b939b86c32559508be3c7f224ba5cfe.tar.gz
puppet-tftp-6500ac722b939b86c32559508be3c7f224ba5cfe.tar.bz2
Merge pull request #7 from thomasvandoren/add-recurse-to-file
Add recurse parameter to tftp::file definition
-rw-r--r--README.md1
-rw-r--r--manifests/file.pp34
-rw-r--r--spec/defines/tftp_file_spec.rb73
3 files changed, 79 insertions, 29 deletions
diff --git a/README.md b/README.md
index 1b3688c..9bd2000 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ Example:
Parameters:
* ensure: file type, default file.
+* recurse: file recurse, default false.
* owner: file owner, default tftp.
* group: file group. default tftp.
* mode: file mode, default 0644 (puppet will change to 0755 for directories).
diff --git a/manifests/file.pp b/manifests/file.pp
index 72c9ebd..ec67f2c 100644
--- a/manifests/file.pp
+++ b/manifests/file.pp
@@ -9,22 +9,30 @@
# Usage:
#
define tftp::file (
- $ensure = file,
- $owner = 'tftp',
- $group = 'tftp',
- $mode = '0644',
- $content = undef,
- $source = undef
+ $ensure = file,
+ $recurse = false,
+ $owner = 'tftp',
+ $group = 'tftp',
+ $mode = '0644',
+ $purge = undef,
+ $replace = undef,
+ $recurselimit = undef,
+ $content = undef,
+ $source = undef
) {
include 'tftp'
file { "${tftp::directory}/${name}":
- ensure => $ensure,
- owner => $owner,
- group => $group,
- mode => $mode,
- content => $content,
- source => $source,
- require => Class['tftp'],
+ ensure => $ensure,
+ recurse => $recurse,
+ owner => $owner,
+ group => $group,
+ mode => $mode,
+ purge => $purge,
+ replace => $replace,
+ recurselimit => $recurselimit,
+ content => $content,
+ source => $source,
+ require => Class['tftp'],
}
}
diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb
index 00072e6..6a032c0 100644
--- a/spec/defines/tftp_file_spec.rb
+++ b/spec/defines/tftp_file_spec.rb
@@ -10,10 +10,11 @@ describe 'tftp::file' do
it { should include_class('tftp') }
it { should contain_file('/srv/tftp/sample').with({
- 'ensure' => 'file',
- 'owner' => 'tftp',
- 'group' => 'tftp',
- 'mode' => '0644'
+ 'ensure' => 'file',
+ 'recurse' => false,
+ 'owner' => 'tftp',
+ 'group' => 'tftp',
+ 'mode' => '0644'
}) }
end
@@ -23,27 +24,67 @@ describe 'tftp::file' do
it { should include_class('tftp') }
it { should contain_file('/var/lib/tftpboot/sample').with({
- 'ensure' => 'file',
- 'owner' => 'tftp',
- 'group' => 'tftp',
- 'mode' => '0644'
+ 'ensure' => 'file',
+ 'recurse' => false,
+ 'owner' => 'tftp',
+ 'group' => 'tftp',
+ 'mode' => '0644'
}) }
end
describe 'when deploying with parameters' do
- let(:params) { {:ensure => 'directory',
- :owner => 'root',
- :group => 'root',
- :mode => '0755' }}
+ let(:params) { {:ensure => 'directory',
+ :recurse => true,
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0755' }}
let(:facts) { { :operatingsystem => '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'
+ 'ensure' => 'directory',
+ 'recurse' => true,
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0755'
+ }) }
+ end
+
+ describe 'when deploying without recurse parameters' do
+ let(:facts) { {:operatingsystem => '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
+ }) }
+ end
+
+ describe 'when deploying with recurse parameters' do
+ let(:params) { {:ensure => 'directory',
+ :recurse => true,
+ :mode => '0755',
+ :recurselimit => 42,
+ :purge => true,
+ :replace => false }}
+ let(:facts) { {:operatingsystem => 'Debian',
+ :path => '/usr/local/bin:/usr/bin:/bin', }}
+
+ it { should include_class('tftp') }
+ it { should contain_file('/srv/tftp/sample').with({
+ 'ensure' => 'directory',
+ 'recurse' => true,
+ 'owner' => 'tftp',
+ 'group' => 'tftp',
+ 'mode' => '0755',
+ 'recurselimit' => 42,
+ 'purge' => true,
+ 'replace' => false,
}) }
end
end