Merge pull request #515 from jfautley/ticket/MODULES-2478-support_root_home_fact_on_AIX
(MODULES-2478) Make root_home fact work on AIX using native lsuser command
This commit is contained in:
commit
9352db77a6
3 changed files with 28 additions and 0 deletions
|
@ -30,3 +30,16 @@ Facter.add(:root_home) do
|
|||
hash['dir'].strip
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add(:root_home) do
|
||||
confine :kernel => :aix
|
||||
root_home = nil
|
||||
setcode do
|
||||
str = Facter::Util::Resolution.exec("lsuser -C -a home root")
|
||||
str && str.split("\n").each do |line|
|
||||
next if line =~ /^#/
|
||||
root_home = line.split(/:/)[1]
|
||||
end
|
||||
root_home
|
||||
end
|
||||
end
|
||||
|
|
2
spec/fixtures/lsuser/root
vendored
Normal file
2
spec/fixtures/lsuser/root
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
#name:home
|
||||
root:/root
|
|
@ -49,4 +49,17 @@ describe 'root_home', :type => :fact do
|
|||
end
|
||||
end
|
||||
|
||||
context "aix" do
|
||||
before do
|
||||
Facter.fact(:kernel).stubs(:value).returns("AIX")
|
||||
Facter.fact(:osfamily).stubs(:value).returns("AIX")
|
||||
end
|
||||
let(:expected_root_home) { "/root" }
|
||||
sample_lsuser = File.read(fixtures('lsuser','root'))
|
||||
|
||||
it "should return /root" do
|
||||
Facter::Util::Resolution.stubs(:exec).with("lsuser -C -a home root").returns(sample_lsuser)
|
||||
expect(Facter.fact(:root_home).value).to eq(expected_root_home)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue