Double reply to myself incoming.
Found a way with chef tags! Wish it came to me earlier.
And check if it’s tagged as an initial chef run in the handler.
initial_chef_run = node.tags.include?(‘initial_chef_run’)
Inspiration from this post:
On Tue, Mar 3, 2015 at 4:53 PM, Roger Lam email@example.com wrote:
Hi Mike and Chefs,
I found the ‘registration_completed’ method under the EventDispatch class.
There’s a section in the Customizing Chef book that overrides event
methods and injects them with start handlers but that’s not exactly
what I’m looking for. Ideally, the code would live in a single
cookbook and not spread to the client.rb or a separate gem as start
I’d love and really appreciate any ideas. Thanks!
On Tue, Feb 24, 2015 at 10:08 AM, Roger Lam firstname.lastname@example.org wrote:
Great idea! I’ll give it a shot. Thank you Mike!
On Tue, Feb 24, 2015 at 6:33 AM, Michael Glenney email@example.com wrote:
While looking at resource counts would probably be mostly accurate (initial
chef runs don’t update 100% of resources but usually way more than re-runs)
it would be problematic.
I would tap the ‘registration_completed’ handler method:
This isn’t necessarily going to be 100% accurate either but it should be
"more" accurate. An example of it not being accurate would be a node that
was deleted from the chef server so it needs to reregister itself. Not an
"initial" run but would trigger this. I think this is an edge case though
as you generally wouldn’t keep the validation pem around on an existing node
so this wouldn’t happen without you knowing about it.
On Mon, Feb 23, 2015 at 11:42 PM, Roger Lam firstname.lastname@example.org wrote:
I’m trying to count the number of initial chef-client runs through
handlers and my initial idea was to compare the number updated
resources with the total number of resources and if they’re equal,
then it’s an initial run. However, this is not the case most of the
time. Has anyone found a way to do this?