Fix aix/windows ownership issues and vardir path

This commit is contained in:
Hunter Haugen 2014-02-26 14:17:59 -08:00
parent eaa84694b1
commit 8b852e2b89
5 changed files with 71 additions and 91 deletions

View file

@ -1,5 +1,17 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'AIX'
username = 'root'
groupname = 'system'
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
else
username = 'root'
groupname = 'root'
end
describe 'basic concat test' do
shared_examples 'successfully_applied' do |pp|
@ -9,12 +21,12 @@ describe 'basic concat test' do
end
end
context 'owner/group root' do
context 'owner/group' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
owner => 'root',
group => 'root',
owner => '#{username}',
group => '#{groupname}',
mode => '0644',
}
@ -35,78 +47,32 @@ describe 'basic concat test' do
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should be_owned_by username }
it { should be_grouped_into groupname }
# XXX file be_mode isn't supported on AIX
it("should be mode 644", :unless => fact('osfamily') == "AIX") {
should be_mode 644
}
it { should contain '1' }
it { should contain '2' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
describe file("#{default.puppet['vardir']}/concat/_tmp_concat_file/fragments/01_1") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
end
end
context 'owner/group non-root' do
before(:all) do
shell "groupadd -g 64444 bob"
shell "useradd -u 42 -g 64444 bob"
end
after(:all) do
shell "userdel bob"
end
pp="
concat { '/tmp/concat/file':
owner => 'bob',
group => 'bob',
mode => '0644',
it { should be_owned_by username }
it { should be_grouped_into groupname }
# XXX file be_mode isn't supported on AIX
it("should be mode 644", :unless => fact('osfamily') == "AIX") {
should be_mode 644
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
order => '02',
}
"
it_behaves_like 'successfully_applied', pp
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_owned_by 'bob' }
it { should be_grouped_into 'bob' }
it { should be_mode 644 }
it { should contain '1' }
it { should contain '2' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
describe file("#{default.puppet['vardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should contain '1' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should contain '2' }
it { should be_owned_by username }
it { should be_grouped_into groupname }
# XXX file be_mode isn't supported on AIX
it("should be mode 644", :unless => fact('osfamily') == "AIX") {
should be_mode 644
}
end
end
end

View file

@ -3,9 +3,8 @@ require 'spec_helper_acceptance'
describe 'concat force empty parameter' do
context 'should run successfully' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
owner => root,
group => root,
mode => '0644',
force => true,
}

View file

@ -1,5 +1,17 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'AIX'
username = 'root'
groupname = 'system'
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
else
username = 'root'
groupname = 'root'
end
describe 'concat::fragment source' do
context 'should read file fragments from local system' do
before(:all) do
@ -49,18 +61,18 @@ describe 'concat::fragment source' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/result_file1':
owner => root,
group => root,
owner => '#{username}',
group => '#{groupname}',
mode => '0644',
}
concat { '/tmp/concat/result_file2':
owner => root,
group => root,
owner => '#{username}',
group => '#{groupname}',
mode => '0644',
}
concat { '/tmp/concat/result_file3':
owner => root,
group => root,
owner => '#{username}',
group => '#{groupname}',
mode => '0644',
}
@ -112,8 +124,8 @@ describe 'concat::fragment source' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/fail_no_source':
owner => root,
group => root,
owner => '#{username}',
group => '#{groupname}',
mode => '0644',
}

View file

@ -116,7 +116,8 @@ describe 'replacement of' do
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
# XXX specinfra doesn't support be_linked_to on AIX
describe file('/tmp/concat/file'), :unless => fact('osfamily') == "AIX" do
it { should be_linked_to '/tmp/concat/dangling' }
end

View file

@ -1,17 +1,19 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
hosts.each do |host|
if host['platform'] =~ /debian/
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
end
if host.is_pe?
install_pe
else
# Install Puppet
install_package host, 'rubygems'
on host, 'gem install puppet --no-ri --no-rdoc'
on host, "mkdir -p #{host['distmoduledir']}"
unless ENV['RS_PROVISION'] == 'no'
hosts.each do |host|
if host['platform'] =~ /debian/
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
end
if host.is_pe?
install_pe
else
# Install Puppet
install_package host, 'rubygems'
on host, 'gem install puppet --no-ri --no-rdoc'
on host, "mkdir -p #{host['distmoduledir']}"
end
end
end
@ -35,7 +37,7 @@ RSpec.configure do |c|
shell('mkdir -p /tmp/concat')
end
c.after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell("rm -rf /tmp/concat #{default.puppet['vardir']}/concat")
end
c.treat_symbols_as_metadata_keys_with_true_values = true