Skip to content

Instantly share code, notes, and snippets.

View teknofire's full-sized avatar

Will Fisher teknofire

View GitHub Profile
@irvingpop
irvingpop / chef-client-cleanup.rb
Created August 6, 2017 17:25
Bit of systemd chef code to have clients automatically remove themselves on shutdown
# Create a systemd service that runs at shutdown to remove one's node and client from the chef server,
# useful in AutoScale and Terraform-managed scenarios
# not useful in cases where you may want to shutdown (but not terminate) a node
systemd_unit 'chef-cleanup.service' do
content('Unit' => {
'Description' => 'Delete my own Chef node and client objects at shutdown/termination',
'DefaultDependencies' => 'no',
'Before' => 'shutdown.target halt.target',
},
@damacus
damacus / foo.sh
Last active March 13, 2018 21:44
Chef Shell in Test Kitchen
sudo /opt/chef/embedded/bin/gem install chef-zero
sudo /opt/chef/embedded/bin/chef-zero -d
knife cookbook upload -a -c /tmp/kitchen/client.rb
# Give it an override runlist
sudo chef-shell -z -c /tmp/kitchen/client.rb -o test::default

Notifications from Resources "Bubble Up"

Release in Chef 12.9.41 via PR #4741 core chef now has a feature which has been available in Poise for awhile, which is that notifications from within resources will now notify resources in outer run contexts. This means you can write a recipe with a service resource and send a notification to it from a resource that you write.

Notifications will bubble up from arbitrarily nested resources, so users that write resources that wrap resources which wrap your resource will still find the service resource in your default recipe.

At the same time the resources collection #find() and #lookup methods and the more commonly-used DSL method resources("service[ntpd]") has been changed to also match