Hello,
Maybe someone can tell me if there’s a better way to do this.
I wrote an LWRPhttp://wiki.opscode.com/display/chef/Light-weight+Resources+and+Providers+(LWRP) that, given a user account, creates the user account, gid, directory, creates user’s authorized_keys. And I often like to use File.directory? or File.exist? and others in my recipes.
If I call File.directory? in a provider, however, Chef interprets it as Chef::Providers::File:Class (or something like that).
So a silly workaround I did was to create libraries/file.rb, and in it:
Class Chef
Class Recipe
Class Plaxo
Require 'ftools’
end
end
end
Then I can call Chef::Recipe::Plaxo::File.directory? and whatnot.
Is there a more elegant way of doing this?
For those who are not familiar with LWRP, I encourage you to check it out. It’s a bit of work to understand and set it, but it allows me to do stuff like:
plaxo_user “opsman” do
action :set
end
Which fetches user info from data bags, creates group, user, sets up user’s authorized_keys, etc. Pretty cool, stuff, this LWRP.
-Paul