How to `knife search` for empty attribute


#1

I have the following roles:

roles/base1.json

“pkgs”: {
“somepkg”: {}
}

roles/base2.json

“pkgs”: {
“somepkg”: {“version”: “1”}
}

How can I use knife search to find base1 and base2 knowing there’s
"somepkg" attribute that can be empty and can be not?

I’ve already tried:

  • knife role search ‘somepkg:*’ # returns only base2
  • knife role search -q ‘-somepkg:*’ # returns all roles
  • knife role search ‘NOT somepkg:*’ # returns all nodes
  • knife role search ‘-somepkg:["" TO *]’ # no results
  • knife role search ‘-somepkg:[* TO *]’ # no results

I’m using the latest version of chef server and client.


Best regards,
Koldaev Anton


#2

Have you tried:

knife role search “pkgs:somepkg*” ?

I didn’t do a whole load of testing, but seemed to work for me with hosted
chef on a node attribute search.

Regards,
Christine

On Mon, May 4, 2015 at 4:42 PM, Anton Koldaev koldaevav@gmail.com wrote:

I have the following roles:

roles/base1.json

“pkgs”: {
“somepkg”: {}
}

roles/base2.json

“pkgs”: {
“somepkg”: {“version”: “1”}
}

How can I use knife search to find base1 and base2 knowing there’s
"somepkg" attribute that can be empty and can be not?

I’ve already tried:

  • knife role search ‘somepkg:*’ # returns only base2
  • knife role search -q ‘-somepkg:*’ # returns all roles
  • knife role search ‘NOT somepkg:*’ # returns all nodes
  • knife role search ‘-somepkg:["" TO *]’ # no results
  • knife role search ‘-somepkg:[* TO *]’ # no results

I’m using the latest version of chef server and client.


Best regards,
Koldaev Anton