[chef] Re: Re: Re: Re: guard only if the owner if folder is ...


Chronological Thread 
  • From: Medya < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: guard only if the owner if folder is ...
  • Date: Tue, 17 Mar 2015 14:01:38 -0500

Thanks Jake, only problem is, the code will fail at compile time ( because during that time recipe hasn't created any folder yet) so when I try to say get my owner of that folder, it fails in compile time....

how can I make that ruby code to run after compile phase?

here is my code

list_of_dir_to_enforce.each do |d|
  uid = File.stat(d).uid
  current_owner =Etc.getpwuid(uid).name
  log "current owner is"+current_owner
    bash "do something on #{d} " do
    not_if current_owner=="medya"
  end
end

On Tue, Mar 17, 2015 at 12:59 PM, Jake Plimack < " target="_blank"> > wrote:
try this

require 'etc'
uid = File.stat('testfile').uid
puts 'Owner name: ', Etc.getpwuid(uid).name

On Tue, Mar 17, 2015 at 11:52 AM, Medya < " target="_blank"> > wrote:
Aj, that is only for UID, that means I means I have to find out another way to find out Uid of a username which I couldn't find in ruby libraries

On Fri, Mar 13, 2015 at 6:18 PM, AJ Christensen < " target="_blank"> > wrote:
Hi Medya,

You can use File::Stat#uid
http://ruby-doc.org/core-2.2.1/File/Stat.html#method-i-uid

Please consider searching before sending questions like this to the
mailing list :-)

cheers,

--aj

On Sat, Mar 14, 2015 at 12:01 PM, Medya < " target="_blank"> > wrote:
> how can I add a guard to a folder that says
> run only_if the owner of /blahblah/ folder is medya ?






Archive powered by MHonArc 2.6.16.

§