[chef] Lazy Attributes outside of resource blocks


Chronological Thread 
  • From: Mathew Crane < >
  • To: chef < >
  • Subject: [chef] Lazy Attributes outside of resource blocks
  • Date: Fri, 28 Aug 2015 13:56:24 -0400

Ohai chefs,

I have an interesting scenario where I need to dynamically update ohai attributes after an action is performed as part of an earlier cookbook during a chef-client run.

Scenario:
- package update runs at start of chef-client run.
- this package update in turn causes the server platform_version.to_f to jump a point release
- This platform_version attribute is used to determine a config (the release jump causes configs to change)

I've tried an ohai reload as part of the package update recipe, but both testing and documentation both indicate this won't work unless I use some sort of lazy or delayed processing to determine this attribute.

As it stands, the package update runs, chef-client completes run as if it was on the older platform_version, and then it updates the other configs 30 minutes later during the next chef-client run.

I understand that these attributes are dialed in during the compilation phase. 

My question is: how do I 'reset' the attributes within the later cookbook outside of the 'lazy' parameter in a resource block? Do I need to use some hackery within a ruby_block to reset an if/else block?

psuedo code:

variable = nil
boolean = false

if #{platform_version.to_f} >= x.y
 variable = something
 boolean = true
end

<snip>

if boolean: 
 file 'somefile'
 end
end

Thanks for any information!



Archive powered by MHonArc 2.6.16.

§