File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,3 +30,16 @@ def get_root_home
3030 hash [ 'dir' ] . strip
3131 end
3232end
33+
34+ Facter . add ( :root_home ) do
35+ confine :kernel => :aix
36+ root_home = nil
37+ setcode do
38+ str = Facter ::Util ::Resolution . exec ( "lsuser -C -a home root" )
39+ str && str . split ( "\n " ) . each do |line |
40+ next if line =~ /^#/
41+ root_home = line . split ( /:/ ) [ 1 ]
42+ end
43+ root_home
44+ end
45+ end
Original file line number Diff line number Diff line change 1+ #name:home
2+ root:/root
Original file line number Diff line number Diff line change 4949 end
5050 end
5151
52+ context "aix" do
53+ before do
54+ Facter . fact ( :kernel ) . stubs ( :value ) . returns ( "AIX" )
55+ Facter . fact ( :osfamily ) . stubs ( :value ) . returns ( "AIX" )
56+ end
57+ let ( :expected_root_home ) { "/root" }
58+ sample_lsuser = File . read ( fixtures ( 'lsuser' , 'root' ) )
59+
60+ it "should return /root" do
61+ Facter ::Util ::Resolution . stubs ( :exec ) . with ( "lsuser -C -a home root" ) . returns ( sample_lsuser )
62+ expect ( Facter . fact ( :root_home ) . value ) . to eq ( expected_root_home )
63+ end
64+ end
5265end
You can’t perform that action at this time.
0 commit comments