|
| 1 | +node.set['supermarket_omnibus']['upgrade_enabled'] = true |
| 2 | +node.set['supermarket_omnibus']['restart_after_upgrades'] = true |
| 3 | + |
| 4 | +unless node['supermarket_omnibus']['upgrade_enabled'] |
| 5 | + Chef::Log.fatal('The supermarket-omnibus-cookbook::upgrade recipe was added to the node,') |
| 6 | + Chef::Log.fatal('however the attribute `node["supermarket_omnibus"]["upgrade_enabled"]` was not set.') |
| 7 | + Chef::Log.fatal('Bailing out here so this node does not upgrade.') |
| 8 | + raise |
| 9 | +end |
| 10 | + |
| 11 | + require 'set' |
| 12 | + |
| 13 | + file "/root/chef_resources-#{node.name}.json" do |
| 14 | + resource_clxn = Chef::ResourceCollection.new |
| 15 | + run_context.resource_collection.each do |r| |
| 16 | + next if r.class.to_s == 'Chef::Resource::NodeMetadata' |
| 17 | + r = r.dup |
| 18 | + r.instance_eval do |
| 19 | + content('') if respond_to?(:content) |
| 20 | + variables({}) if respond_to?(:variables) |
| 21 | + remove_instance_variable('@options') rescue nil |
| 22 | + params.delete(:options) if respond_to?(:params) |
| 23 | + # if respond_to?(:options) |
| 24 | + # begin ; options({}) ; rescue options('') ; end |
| 25 | + # end |
| 26 | + @delayed_notifications = [] |
| 27 | + @immediate_notifications = [] |
| 28 | + end |
| 29 | + resource_clxn << r |
| 30 | + end |
| 31 | + content resource_clxn.to_json(JSON::PRETTY_STATE_PROTOTYPE)+"\n" |
| 32 | + action :create |
| 33 | + owner 'root' |
| 34 | + group 'root' |
| 35 | + mode "0600" # only readable by root |
| 36 | + end |
| 37 | + |
| 38 | +#walk_resource_path |
| 39 | + |
| 40 | +#resources(apt_package: 'supermarket').notifies :reconfigure, 'supermarket_server[supermarket]' |
| 41 | +#resources(supermarket_server: 'supermarket').notifies :reconfigure, 'supermarket_server[supermarket]' |
| 42 | +#resources(Chef::Resource::SupermarketServer::chef_ingredient: 'supermarket').notifies :reconfigure, 'supermarket_server[supermarket]' |
| 43 | +#resources(supermarket_server: 'supermarket').action :upgrade |
0 commit comments