Skip to content

Instantly share code, notes, and snippets.

@gerhard
Created January 9, 2012 21:57
Show Gist options
  • Save gerhard/1585177 to your computer and use it in GitHub Desktop.
Save gerhard/1585177 to your computer and use it in GitHub Desktop.
Extending chef providers
include Chef::Provider::SystemUser
action :create do
# super ?
# rvm specific work...
end
include Chef::Resource::SystemUser
# nothing is different from system/resources/user.rb
action :create do
# work
end
actions :create#, others...
attribute :name, :kind_of => String
attribute :password, :kind_of => String, :default => ''
def initialize(*args)
super
@action = :create
end
@gerhard
Copy link
Author

gerhard commented Jan 9, 2012

Getting this when running chef-solo:

NameError: uninitialized constant Chef::Providers
/root/chef/cookbooks/rvm/providers/user.rb:1:in `class_from_file'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/provider.rb:110:in `build_from_file'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/provider.rb:92:in `initialize'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/provider.rb:92:in `new'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/provider.rb:92:in `build_from_file'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:89
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:120:in `call'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:120:in `foreach_cookbook_load_segment'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:119:in `each'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:119:in `foreach_cookbook_load_segment'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:117:in `each'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:117:in `foreach_cookbook_load_segment'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:87:in `load_lwrp_providers'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/run_context.rb:58:in `load'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/client.rb:195:in `setup_run_context'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/client.rb:159:in `run'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application/solo.rb:192:in `run_application'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application/solo.rb:183:in `loop'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application/solo.rb:183:in `run_application'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application.rb:67:in `run'
/usr/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/chef-solo:25
/usr/bin/chef-solo:19:in `load'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment