From e29cbb8be4347a471edae244aef6c26faada38bc Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Wed, 11 Jul 2012 16:41:17 -0700 Subject: Update redhat tftp file owner. This update address file owner to nobody by default for RHEL family. --- .fixtures.yml | 2 +- manifests/file.pp | 21 +++++++++++++++++---- spec/defines/tftp_file_spec.rb | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index a38b2cb..970cd59 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,5 +1,5 @@ fixtures: repositories: - "inetd": "git://github.com/puppetlabs/puppetlabs-inetd.git" + "xinetd": "git://github.com/puppetlabs/puppetlabs-xinetd.git" symlinks: "tftp": "#{source_dir}" diff --git a/manifests/file.pp b/manifests/file.pp index 3628188..48a5fab 100644 --- a/manifests/file.pp +++ b/manifests/file.pp @@ -29,8 +29,8 @@ # define tftp::file ( $ensure = file, - $owner = 'tftp', - $group = 'tftp', + $owner = undef, + $group = undef, $mode = '0644', $recurse = false, $purge = undef, @@ -40,6 +40,19 @@ define tftp::file ( $source = undef ) { include 'tftp' + include 'tftp::params' + + if $owner { + $tftp_owner = $owner + } else { + $tftp_owner = $tftp::params::username + } + + if $group { + $tftp_group = $group + } else { + $tftp_group = $tftp::params::username + } if $source { $source_real = $source @@ -54,8 +67,8 @@ define tftp::file ( file { "${tftp::directory}/${name}": ensure => $ensure, - owner => $owner, - group => $group, + owner => $tftp_owner, + group => $tftp_group, mode => $mode, recurse => $recurse, purge => $purge, diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb index e24f0f3..38f34a6 100644 --- a/spec/defines/tftp_file_spec.rb +++ b/spec/defines/tftp_file_spec.rb @@ -38,6 +38,23 @@ describe 'tftp::file' do } end + describe 'when deploying on redhat' do + let(:facts) { { :operatingsystem => 'RedHat', + :osfamily => 'redhat', + :path => '/usr/local/bin:/usr/bin:/bin', } } + + it { + should include_class('tftp') + should contain_file('/var/lib/tftpboot/sample').with({ + 'ensure' => 'file', + 'owner' => 'nobody', + 'group' => 'nobody', + 'mode' => '0644', + 'recurse' => false, + }) + } + end + describe 'when deploying with parameters' do let(:params) { {:ensure => 'directory', :owner => 'root', -- cgit v1.2.3