Pages

Thursday 21 September 2017

Attribute path for chef searches

Do I need to specify the full path for the attribute when doing a search in chef?

Given that you have a node with some attributes (see that fqdn is a nested attribute)

root@crowbar:~ # knife node show d52-54-77-77-01-01.virtual.cloud.suse.de -F json | head
{
  "name": "d52-54-77-77-01-01.virtual.cloud.suse.de",
  "chef_environment": "_default",
  "run_list": [
    "role[crowbar-d52-54-77-77-01-01_virtual_cloud_suse_de]"
  ],
  "normal": {
    "fqdn": "d52-54-77-77-01-01.virtual.cloud.suse.de",
    "crowbar": {
      "network": {

You want to do some searches:

root@crowbar:~ # knife search node 'name:d52-54-77-77-01-01.virtual.cloud.suse.de' -i
1 items found


d52-54-77-77-01-01.virtual.cloud.suse.de

And if you are interested in the fqdn, you do not need to specify the full path:

root@crowbar:~ # knife search node 'fqdn:d52-54-77-77-01-01.virtual.cloud.suse.de' -i
1 items found

d52-54-77-77-01-01.virtual.cloud.suse.de