[chef] Re: Check for changed attribute values


Chronological Thread 
  • From: "Stewart, Curtis" < >
  • To: " " < >
  • Subject: [chef] Re: Check for changed attribute values
  • Date: Wed, 19 Mar 2014 14:15:24 +0000
  • Accept-language: en-US

I really like the file idea.  It allows use of notifications.  We’ll try to look into that.

Thanks for the feedback!

Curtis

On Mar 19, 2014, at 9:07 AM, Jeremy Mauro < "> > wrote:

One way to do it would be keep some kind of changelog of the value into a file for example then ‘subscribe an action’:
file ‘/var/cache/chef/gitbranch’ do
  content node[‘someattributs’]
  notifies :run, ‘whatever resource I want’
end
 
 
 
From: Joe Nuspl [ ">mailto: ] 
Sent: mardi 18 mars 2014 18:10
To:  ">
Subject: [chef] Re: Check for changed attribute values
 
Within a chef client run?  You could do something like…
 
            last = Chef::Node.load(node.name)
            if last.default[‘some-attribute’] != node.default[‘some-attribute’]
                        # do something
            end
 
This only works is you call Chef::Node.load before any recipe does a "node.save”.  Substitute “override” for “default” if you’re looking at overrides.
 
If external to a client run and you are loading node attributes via role/cookbook/data_bag backed by git, you could use "knife node show” and compare that to what the new code would load and then execute rake.
 
Hope this helps.
 
            Joe
 


Is there anyway to check if a node attribute has changed since the last chef-client run?
 
My particular case is to run a rake task ONLY IF the specified git branch attribute has changed since the last chef-client run.
 
Thanks,
Curtis




Archive powered by MHonArc 2.6.16.

§