Skip to content

Instantly share code, notes, and snippets.

@maoueh
Last active December 9, 2015 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maoueh/f85c30d7869294d928c4 to your computer and use it in GitHub Desktop.
Save maoueh/f85c30d7869294d928c4 to your computer and use it in GitHub Desktop.
Chef bug custom resources and include_recipe
# cookbooks/app/recipes/default.rb
include_recipe 'common::default'
# cookbooks/common/recipes/default.rb
log 'Should log first (in common::default).'
include Chef::DSL::IncludeRecipe
action :execute do
log "In LWRP, before include_recipe 'root::bootstrap'"
include_recipe 'root::bootstrap'
log "In LWRP, after include_recipe 'root::bootstrap'"
end
# cookbooks/root/recipes/bootstrap.rb
include_recipe 'common::default'
log 'Should log second (in root::boostrap).'
# cookbooks/root/recipes/default.rb
root_prepare 'id'
include_recipe 'app::default'
log 'Should log third (in root::default).'
# cookbooks/root/resources/prepare.rb
actions :execute
default_action :execute
attribute :name, :kind_of => String, :name_attribute => true
[root@host sample]# chef-client -z -o 'root'
[2015-12-09T16:13:13+00:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.4.3
[2015-12-09T16:13:15+00:00] WARN: Run List override has been provided.
[2015-12-09T16:13:15+00:00] WARN: Original Run List: []
[2015-12-09T16:13:15+00:00] WARN: Overridden Run List: [recipe[root]]
resolving cookbooks for run list: ["root"]
Synchronizing Cookbooks:
- common
- app
- root
Compiling Cookbooks...
Converging 3 resources
Recipe: root::default
* root_prepare[id] action execute (up to date)
* log[In LWRP, before include_recipe 'root::bootstrap'] action write
Recipe: root::bootstrap
* log[Should log second (in root::boostrap).] action write
* log[In LWRP, after include_recipe 'root::bootstrap'] action write
Recipe: common::default
* log[Should log first (in common::default).] action write
Recipe: root::default
* log[Should log third (in root::default).] action write
[2015-12-09T16:13:15+00:00] WARN: Skipping final node save because override_runlist was given
Running handlers:
Running handlers complete
Chef Client finished, 5/6 resources updated in 2.154498603 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment