Knife search'ing for an inherited recipe?


#1

Hi! Is there a way to “knife search node” for all of the nodes that have a
specific recipe, regardless of which role has included the recipe in the
run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy


#2

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that have a specific recipe, regardless of which role has included the recipe in the run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get run via include_recipe, though.


Daniel DeLeo


#3

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node 'run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.com wrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that have
a specific recipe, regardless of which role has included the recipe in the
run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get run
via include_recipe, though.


Daniel DeLeo


#4

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.com wrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that have
a specific recipe, regardless of which role has included the recipe in the
run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get
run via include_recipe, though.


Daniel DeLeo


#5

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.com wrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that
have a specific recipe, regardless of which role has included the recipe in
the run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get
run via include_recipe, though.


Daniel DeLeo


#6

Any idea how to search for recipes that were inherited due to
include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz guymatz@gmail.com wrote:

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.com wrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that
have a specific recipe, regardless of which role has included the recipe in
the run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get
run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.


#7

Hi,

There is no easy way that I know of so what we do is store all the
visited recipes via snippet of code in our run list. It looks
something like the following. Then we just search on the attribute we
created

ruby_block ‘get_seen_recipes’ do
block do
node.override[‘knife_audit’][‘seen_recipes’] = run_context.loaded_recipes
end
action :create
end

On Fri, Oct 18, 2013 at 3:44 PM, DV vindimy@gmail.com wrote:

Any idea how to search for recipes that were inherited due to
include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz guymatz@gmail.com wrote:

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion., hence
you can search the recipes (as well as roles) attribute, they are top level
node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.com wrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that
have a specific recipe, regardless of which role has included the recipe in
the run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get
run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.


Cheers,

Peter Donald


#8

theres no direct way, at pagerduty we use a handler , pd-chef-handler to do
this. it stores run_status.run_context.loaded_recipes.uniq as a node
attribute (node.chef_client.metrics). this, will always contain all the
included recipes for a successfully converged node. but i think its a bad
to search against recipes that are not top level (i.e part of a role or
directly inside the run_list),

On Thu, Oct 17, 2013 at 9:44 PM, DV vindimy@gmail.com wrote:

Any idea how to search for recipes that were inherited due to
include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz guymatz@gmail.com wrote:

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.comwrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that
have a specific recipe, regardless of which role has included the recipe in
the run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve
tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that get
run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.


#9

For certain cookbook I’m using attributes as marker. If I have, for example
gmond recipe (ganglia monitor daemon) I’m setting node.ganglia.recipe.gmond
true. And search for this.
But, hardcoded search is bad practice: somebody uses roles, somebody
wrapper-cookbook or library.
That’s why new best practice for me is using search_query_attribute. I’ll
actually be able overwrite it in role, cookbook, node attributes, etc.
Works fine for me.
Real use case: nagios cookbook. I can’t use it because I haven’t roles and
use wrapper. For me it is:

  • no host groups
  • no search

Next step of evolution is move search attributes from attributes folder to
helper recipe “_search_attributes.rb”. This change incorporate new ability
to use overridden attributes from wrapped cookbook.
Use Case:

query = []
query << "chef_environment:#{node.chef_environment}"
query << "my_custom_attribute_one:#{node.my.attr.one}"
query << "my_custom_attribute_two:#{node.my.attr.two}"
node.default[‘myrecipe’][‘search’][‘entity’] = query.join(’ AND ')

If this code located in attributes folder it evaluates at very begin of
chef run and I can’t override attributes from other cookbooks. Moving to
recipe gives me possibility to override only one attribute:
node.override.my.attr.two = "different attr"
include_recipe “myrecipe” # which actually the includes
_search_attributes.rb recipe and will use new value

If you have very different environment you still able to override whole
search query as you need:
node.override.myrecipe.search.entity = “recipe:my-wrapper”

Cookbook sample of ganglia: https://github.com/jsirex/cookbook-ganglia

2013/10/18 Ranjib Dey dey.ranjib@gmail.com

theres no direct way, at pagerduty we use a handler , pd-chef-handler to
do this. it stores run_status.run_context.loaded_recipes.uniq as a node
attribute (node.chef_client.metrics). this, will always contain all the
included recipes for a successfully converged node. but i think its a bad
to search against recipes that are not top level (i.e part of a role or
directly inside the run_list),

On Thu, Oct 17, 2013 at 9:44 PM, DV vindimy@gmail.com wrote:

Any idea how to search for recipes that were inherited due to
include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz guymatz@gmail.com wrote:

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.comwrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.comwrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that
have a specific recipe, regardless of which role has included the recipe in
the run_list?

I have a recipe called bondage::dns that is in a few roles . . .
I’ve tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that
get run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.


#10

There’s a fundamental problem. Recipes may be included on a contingency basis, such as “only on centos systems” or “only if I’m an apache server”, or “only if I have this setting loaded from a data bag”. So reverse analyzing what recipes were included is like asking “what line of code caused this bit to flip”. With luck, you can reverse engineer it from good coding practices, but in the real world, you can’t be certain unless you know everything about the original environment.

And the original environment may change from moment to moment, especially if someone’s been editing your data bags or cookbooks manually.


From: DV [vindimy@gmail.com]
Sent: Friday, October 18, 2013 12:44 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Re: Re: Re: knife search’ing for an inherited recipe?

Any idea how to search for recipes that were inherited due to include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz <guymatz@gmail.commailto:guymatz@gmail.com> wrote:
Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey <dey.ranjib@gmail.commailto:dey.ranjib@gmail.com> wrote:
just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles) into an attribute named “recipes”, as part of the run list expansion., hence you can search the recipes (as well as roles) attribute, they are top level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz <guymatz@gmail.commailto:guymatz@gmail.com> wrote:
No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node 'run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh, users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python, screen, nscd, openssh, motd-tail, operations, logrotate::syslog, vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop, bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo <dan@kallistec.commailto:dan@kallistec.com> wrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes that have a specific recipe, regardless of which role has included the recipe in the run_list?

I have a recipe called bondage::dns that is in a few roles . . . I’ve tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy
search for recipes with an ‘s’. This won’t pick up recipes that get run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.


#11

If you want your include_recipe’d recipe to be found with search, leave
some evidence in the node object with an attribute.

node.normal[‘somecookbook’][‘somerecipe’][‘included’] = true

-s

On Sun, Oct 20, 2013 at 8:19 AM, Kadel-Garcia, Nico <
NKadelGarcia-consultant@scholastic.com> wrote:

There’s a fundamental problem. Recipes may be included on a contingency
basis, such as “only on centos systems” or “only if I’m an apache server”,
or “only if I have this setting loaded from a data bag”. So reverse
analyzing what recipes were included is like asking “what line of code
caused this bit to flip”. With luck, you can reverse engineer it from good
coding practices, but in the real world, you can’t be certain unless you
know everything about the original environment.

And the original environment may change from moment to moment,
especially if someone’s been editing your data bags or cookbooks manually.


From: DV [vindimy@gmail.com]
Sent: Friday, October 18, 2013 12:44 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Re: Re: Re: knife search’ing for an inherited
recipe?

Any idea how to search for recipes that were inherited due to
include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz guymatz@gmail.com wrote:

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.comwrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes
that have a specific recipe, regardless of which role has included the
recipe in the run_list?

I have a recipe called bondage::dns that is in a few roles . . .
I’ve tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that
get run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.


#12

In some recipes I use tags that are set in the recipe to denote some
property that I know I want to find outside the recipe. In this way I am
not tied to a role or run_list for this info.

On Sun, Oct 20, 2013 at 5:19 AM, Kadel-Garcia, Nico <
NKadelGarcia-consultant@scholastic.com> wrote:

There’s a fundamental problem. Recipes may be included on a contingency
basis, such as “only on centos systems” or “only if I’m an apache server”,
or “only if I have this setting loaded from a data bag”. So reverse
analyzing what recipes were included is like asking “what line of code
caused this bit to flip”. With luck, you can reverse engineer it from good
coding practices, but in the real world, you can’t be certain unless you
know everything about the original environment.

And the original environment may change from moment to moment,
especially if someone’s been editing your data bags or cookbooks manually.


From: DV [vindimy@gmail.com]
Sent: Friday, October 18, 2013 12:44 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Re: Re: Re: knife search’ing for an inherited
recipe?

Any idea how to search for recipes that were inherited due to
include_recipe?

On Mon, Oct 14, 2013 at 2:05 PM, Guy Matz guymatz@gmail.com wrote:

Sweet!!!

On Mon, Oct 14, 2013 at 4:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

just do knife search node "recipes:foo",

chef stores all the recipes (defined in run_list directly or via roles)
into an attribute named “recipes”, as part of the run list expansion.,
hence you can search the recipes (as well as roles) attribute, they are top
level node attributes

On Mon, Oct 14, 2013 at 1:34 PM, Guy Matz guymatz@gmail.com wrote:

No, that didn’t do the trick, if I understood you correctly:
[gmatz@bunnybear /]$ knife search node
’run_list:recipes[bondage::dns]'
0 items found

however:
[gmatz@bunnybear /] knife search node 'role:iad-web' | grep bondage::dns | wc -l 11 [gmatz@bunnybear /] knife search node ‘role:auto-bonded’ | grep
bondage::dns | wc -l
18
[gmatz@bunnybear /]$ knife search node ‘role:auto-bonded’ | head
18 items found

Node Name: iad-hadoop105.ihr
Environment: _default
FQDN: iad-hadoop105.ihr
IP: 10.5.40.169
Run List: role[base], role[hadoop], role[auto-bonded]
Roles: sendmail-smart-host, auto-bonded, base, hadoop
Recipes: resolver, yum, ntp, timezone, cron, chef-client, zsh,
users::sysadmins, sudo, emacs, vim, git, build-essential, perl, python,
screen, nscd, openssh, motd-tail, operations, logrotate::syslog,
vmware-tools::noop, sendmail, sendmail::sendmail_smart_host, users::hadoop,
bondage::dns
Platform: centos 6.3

Thanks again!

On Mon, Oct 14, 2013 at 4:21 PM, Daniel DeLeo dan@kallistec.comwrote:

On Monday, October 14, 2013 at 1:19 PM, Guy Matz wrote:

Hi! Is there a way to “knife search node” for all of the nodes
that have a specific recipe, regardless of which role has included the
recipe in the run_list?

I have a recipe called bondage::dns that is in a few roles . . .
I’ve tried this, but it didn’t work:
knife search node ‘run_list:recipe[bondage::dns]’

Any help would be greatly appreciated!

Thanks,
Guy

search for recipes with an ‘s’. This won’t pick up recipes that
get run via include_recipe, though.


Daniel DeLeo


Best regards, Dmitriy V.