Search if a recipe is part of the run-list, including all indirectly included recipes

how can i search if a node ran recipe “x” in it’s last chef-run? i don’t
care if “x” was directly in the run-list, part of a role that was part of
the run-list, or if it was included in another recipe in the run-list (so a
include_recipe “x” somewhere)

search(:node,"recipes:foo")

note. the attribute recipes (against which we are searching here) is
populated as per the run list expansion process and stored in the chef
server after a successful chef run. Which means it will not include a
node(including the self node) that has not gone through at least 1
successful chef run.

regards
ranjib

On Tue, May 28, 2013 at 2:10 PM, Koert Kuipers koert@tresata.com wrote:

how can i search if a node ran recipe "x" in it's last chef-run? i don't
care if "x" was directly in the run-list, part of a role that was part of
the run-list, or if it was included in another recipe in the run-list (so a
include_recipe "x" somewhere)

i tried this and it expands roles but not recipes.

so if recipe y is in the run-list and recipe y has a 'include_recipe "x"',
then search(:node,"recipes:x") does not work

On Tue, May 28, 2013 at 5:14 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

search(:node,"recipes:foo")

note. the attribute recipes (against which we are searching here) is
populated as per the run list expansion process and stored in the chef
server after a successful chef run. Which means it will not include a
node(including the self node) that has not gone through at least 1
successful chef run.

regards
ranjib

On Tue, May 28, 2013 at 2:10 PM, Koert Kuipers koert@tresata.com wrote:

how can i search if a node ran recipe "x" in it's last chef-run? i don't
care if "x" was directly in the run-list, part of a role that was part of
the run-list, or if it was included in another recipe in the run-list (so a
include_recipe "x" somewhere)

Currently, recipes included via the "include_recipe" directive leave no
"evidence" they were included in the node object unless they were
specifically written to.

As a quick work around, you can put this on the droids you're looking for:

node.set['cookbook_name']['recipe_name']['beacon'] = true

-s

On Tue, May 28, 2013 at 5:16 PM, Koert Kuipers koert@tresata.com wrote:

i tried this and it expands roles but not recipes.

so if recipe y is in the run-list and recipe y has a 'include_recipe "x"',
then search(:node,"recipes:x") does not work

On Tue, May 28, 2013 at 5:14 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

search(:node,"recipes:foo")

note. the attribute recipes (against which we are searching here) is
populated as per the run list expansion process and stored in the chef
server after a successful chef run. Which means it will not include a
node(including the self node) that has not gone through at least 1
successful chef run.

regards
ranjib

On Tue, May 28, 2013 at 2:10 PM, Koert Kuipers koert@tresata.com wrote:

how can i search if a node ran recipe "x" in it's last chef-run? i don't
care if "x" was directly in the run-list, part of a role that was part of
the run-list, or if it was included in another recipe in the run-list (so a
include_recipe "x" somewhere)

ah okay thanks! that is what i am currently doing. i was wondering if there
was a better way

On Tue, May 28, 2013 at 5:21 PM, Sean OMeara someara@gmail.com wrote:

Currently, recipes included via the "include_recipe" directive leave no
"evidence" they were included in the node object unless they were
specifically written to.

As a quick work around, you can put this on the droids you're looking for:

node.set['cookbook_name']['recipe_name']['beacon'] = true

-s

On Tue, May 28, 2013 at 5:16 PM, Koert Kuipers koert@tresata.com wrote:

i tried this and it expands roles but not recipes.

so if recipe y is in the run-list and recipe y has a 'include_recipe
"x"', then search(:node,"recipes:x") does not work

On Tue, May 28, 2013 at 5:14 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

search(:node,"recipes:foo")

note. the attribute recipes (against which we are searching here) is
populated as per the run list expansion process and stored in the chef
server after a successful chef run. Which means it will not include a
node(including the self node) that has not gone through at least 1
successful chef run.

regards
ranjib

On Tue, May 28, 2013 at 2:10 PM, Koert Kuipers koert@tresata.comwrote:

how can i search if a node ran recipe "x" in it's last chef-run? i
don't care if "x" was directly in the run-list, part of a role that was
part of the run-list, or if it was included in another recipe in the
run-list (so a include_recipe "x" somewhere)

Hi,

I don't have the link with me but the knife-audit plugin includes a snippet
that adds the full set of "seen" recipes as a node attribute. This what we
use to record the recipes run. Also I would highly recommend that you do
NOT record the recipes in normal precedence as they will persist between
runs

On Wednesday, May 29, 2013, Koert Kuipers wrote:

ah okay thanks! that is what i am currently doing. i was wondering if
there was a better way

On Tue, May 28, 2013 at 5:21 PM, Sean OMeara <someara@gmail.com<javascript:_e({}, 'cvml', 'someara@gmail.com');>

wrote:

Currently, recipes included via the "include_recipe" directive leave no
"evidence" they were included in the node object unless they were
specifically written to.

As a quick work around, you can put this on the droids you're looking for:

node.set['cookbook_name']['recipe_name']['beacon'] = true

-s

On Tue, May 28, 2013 at 5:16 PM, Koert Kuipers <koert@tresata.com<javascript:_e({}, 'cvml', 'koert@tresata.com');>

wrote:

i tried this and it expands roles but not recipes.

so if recipe y is in the run-list and recipe y has a 'include_recipe
"x"', then search(:node,"recipes:x") does not work

On Tue, May 28, 2013 at 5:14 PM, Ranjib Dey <dey.ranjib@gmail.com<javascript:_e({}, 'cvml', 'dey.ranjib@gmail.com');>

wrote:

search(:node,"recipes:foo")

note. the attribute recipes (against which we are searching here) is
populated as per the run list expansion process and stored in the chef
server after a successful chef run. Which means it will not include a
node(including the self node) that has not gone through at least 1
successful chef run.

regards
ranjib

On Tue, May 28, 2013 at 2:10 PM, Koert Kuipers <koert@tresata.com<javascript:_e({}, 'cvml', 'koert@tresata.com');>

wrote:

how can i search if a node ran recipe "x" in it's last chef-run? i
don't care if "x" was directly in the run-list, part of a role that was
part of the run-list, or if it was included in another recipe in the
run-list (so a include_recipe "x" somewhere)

--
Cheers,

Peter Donald