diff --git a/manifests/setup.pp b/manifests/setup.pp index 95cce4a..82a082f 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -1,65 +1,67 @@ # === Class: concat::setup # # Sets up the concat system. This is a private class. # # [$concatdir] # is where the fragments live and is set on the fact concat_basedir. # Since puppet should always manage files in $concatdir and they should # not be deleted ever, /tmp is not an option. # # It also copies out the concatfragments.{sh,rb} file to ${concatdir}/bin # class concat::setup { if $caller_module_name != $module_name { warning("${name} is deprecated as a public API of the ${module_name} module and should no longer be directly included in the manifest.") } if $::concat_basedir { $concatdir = $::concat_basedir } else { fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } # owner,group and mode of fragment files (on windows owner and access rights should # be inherited from concatdir and not explicitly set to avoid problems) $fragment_owner = $::osfamily ? { 'windows' => undef, default => $::id } $fragment_mode = $::osfamily ? { 'windows' => undef, default => '0640' } # test on gid fact availability to support older facter versions if defined('$gid') and $::gid and $::osfamily != 'Windows' { $fragment_group = $::gid } else { $fragment_group = undef } $script_name = 'concatfragments.rb' $script_path = "${concatdir}/bin/${script_name}" - $script_owner = $::osfamily ? { 'windows' => undef, default => $::id } + $default_owner = $::osfamily ? { 'windows' => undef, default => $::id } - $script_group = $script_owner ? { 'root' => '0', default => undef } + $default_group = $default_owner ? { 'root' => '0', default => undef } $script_mode = $::osfamily ? { 'windows' => undef, default => '0755' } $script_command = $::osfamily? { 'windows' => "ruby.exe '${script_path}'", default => $script_path } File { backup => false, } file { $script_path: ensure => file, - owner => $script_owner, - group => $script_group, + owner => $default_owner, + group => $default_group, mode => $script_mode, source => "puppet:///modules/concat/${script_name}", } file { [ $concatdir, "${concatdir}/bin" ]: ensure => directory, + owner => $default_owner, + group => $default_group, mode => '0755', } } diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index e97a29c..84ba282 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -1,96 +1,102 @@ require 'spec_helper' describe 'concat::setup', :type => :class do shared_examples 'setup' do |concatdir| concatdir = '/foo' if concatdir.nil? let(:facts) do { :concat_basedir => concatdir, :caller_module_name => 'Test', :osfamily => 'Debian', :id => 'root', :is_pe => false, } end it do should contain_file("#{concatdir}/bin/concatfragments.rb").with({ :mode => '0755', + :owner => 'root', + :group => 0, :source => 'puppet:///modules/concat/concatfragments.rb', :backup => false, }) end [concatdir, "#{concatdir}/bin"].each do |file| it do should contain_file(file).with({ :ensure => 'directory', :mode => '0755', + :owner => 'root', + :group => 0, :backup => false, }) end end end context 'facts' do context 'concat_basedir =>' do context '/foo' do it_behaves_like 'setup', '/foo' end end end # facts context 'deprecated as a public class' do it 'should create a warning' do skip('rspec-puppet support for testing warning()') end end context "on osfamily Solaris" do concatdir = '/foo' let(:facts) do { :concat_basedir => concatdir, :caller_module_name => 'Test', :osfamily => 'Solaris', :id => 'root', :is_pe => false, } end it do should contain_file("#{concatdir}/bin/concatfragments.rb").with({ :ensure => 'file', :owner => 'root', + :group => 0, :mode => '0755', :source => 'puppet:///modules/concat/concatfragments.rb', :backup => false, }) end end # on osfamily Solaris context "on osfamily windows" do concatdir = '/foo' let(:facts) do { :concat_basedir => concatdir, :caller_module_name => 'Test', :osfamily => 'windows', :id => 'batman', :is_pe => false, } end it do should contain_file("#{concatdir}/bin/concatfragments.rb").with({ :ensure => 'file', :owner => nil, + :group => nil, :mode => nil, :source => 'puppet:///modules/concat/concatfragments.rb', :backup => false, }) end end # on osfamily windows end