Why I cannot search by recipes attribute only. Other attributes in search are still working


#1

$knife search node “recipes:cftp”

knife search node “hostname:zeus” -l | grep -C 10 recipes
metric: 256
proto: kernel
state: unknown
type: vnet
ohai_time: 1376978220.81941
os: linux
os_version: 3.5.0-34-generic
platform: ubuntu
platform_family: debian
platform_version: 12.04
recipes:
apt
ntp
cftp
cnfs::server
cinotify
nut
fail2ban
csquiddebproxy::server
csquiddebproxy
cbacula::client

OR other example:

knife search node “roles:ntp_server” -l | grep -C 10 roles
apt
ntp
cftp
cnfs::server
cinotify
nut
fail2ban
csquiddebproxy::server
csquiddebproxy
cbacula::client
roles:
ntp_server
nut_apcrt5000xl_serverroom_server
uptime: 6 days 21 hours 09 minutes 00 seconds
uptime_seconds: 594540
virtualization:
role: host
system: kvm

What is the difference between roles and recipes attributes. Why with
recipes search are not work ?

Thank you very much.


Best regards,

CVisionLab System Administrator
Vladmir Skubriev


#2

Recipes and roles are two node attributes, populated during node building,
as part of chef run (check client.rb for phases in a chef run). Iteresting
values of these two attributes comes from run list expansions, which
populates an array of recipe as it parses the items in run list. Note, both
are automatic attributes, some thing similar to ohai.
Now,
if you want to check all recipes against a node, if you can use the
run_context.loaded_recipes (most probably). this trick will work as long as
you are searching against the current running node and the recipe you are
searching is included before the code block where you are checking this.

We internally use a handler that exposes these info as
node.chef_metrics.loaded_recipes (with few other staff).




On Mon, Aug 19, 2013 at 11:27 PM, Vladimir Skubriev <skubriev@cvisionlab.com

wrote:

$knife search node “recipes:cftp”

knife search node “hostname:zeus” -l | grep -C 10 recipes
metric: 256
proto: kernel
state: unknown
type: vnet
ohai_time: 1376978220.81941
os: linux
os_version: 3.5.0-34-generic
platform: ubuntu
platform_family: debian
platform_version: 12.04
recipes:
apt
ntp
cftp
cnfs::server
cinotify
nut
fail2ban
csquiddebproxy::server
csquiddebproxy
cbacula::client

OR other example:

knife search node “roles:ntp_server” -l | grep -C 10 roles
apt
ntp
cftp
cnfs::server
cinotify
nut
fail2ban
csquiddebproxy::server
csquiddebproxy
cbacula::client
roles:
ntp_server
nut_apcrt5000xl_serverroom_**server
uptime: 6 days 21 hours 09 minutes 00 seconds
uptime_seconds: 594540
virtualization:
role: host
system: kvm

What is the difference between roles and recipes attributes. Why with
recipes search are not work ?

Thank you very much.


Best regards,

CVisionLab System Administrator
Vladmir Skubriev


#3

On Tue, Aug 20, 2013 at 2:27 AM, Vladimir Skubriev
skubriev@cvisionlab.com wrote:

What is the difference between roles and recipes attributes. Why with
recipes search are not work ?

In addition to Ranjib’s explanation, there’s documentation here:

http://docs.opscode.com/essentials_search.html#roles-in-run-lists
http://docs.opscode.com/essentials_search.html#nodes

Bryan