Skip to content

Instantly share code, notes, and snippets.

@rlister
Created August 27, 2014 19:57
Show Gist options
  • Save rlister/1e8025c0f97b2482b4b2 to your computer and use it in GitHub Desktop.
Save rlister/1e8025c0f97b2482b4b2 to your computer and use it in GitHub Desktop.
force ohai ec2 plugin for aws instances
## for an unknown reason, on a subset of instances the
## ohai ec2 data is not populated unless this file exists
## so touch it until we figure out why
[ '/etc/chef', '/etc/chef/ohai', '/etc/chef/ohai/hints' ].each do |dir|
directory(dir).run_action(:create)
end
## this plugin file just needs to exist to able the plugin
ec2_json = file '/etc/chef/ohai/hints/ec2.json' do
content ''
end
## create during compile phase
ec2_json.run_action(:create)
## reloads node attributes during run
reload_ec2 = ohai 'reload_ec2' do
plugin 'ec2'
action :nothing
end
## force the reload now if plugin updated
if ec2_json.updated?
reload_ec2.run_action(:reload)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment