Search code examples
chef-infrachef-recipecookbookrecipe

Can I force a node to send its node object to chef server mid-recipe execution?


I'm doing this in a recipe:

tag('mytag')
nodeobjs = search(:node, 'tags:mytag')

On first run on a node search() won't find it (until it runs again).

I know the nodes build a local copy of their node object before sending it too the server. Is it possible to force the node to propagate its node object mid-recipe execution?

I could obviously tag the node in a different recipe that runs before this recipe in the run list, but I was just curious if it is possible to call tag('mytag') and have that change immediately propagated.


Solution

  • Technically yes but really really don't. You'll need to add a check for the local node that looks at local data, otherwise even with a node.save you have indexer lag to deal with.