How to - List the nodes being managed by a role

#1

Community,

Hopefully this turns out to be an easy answer. Wanted to know if there is a way to get a list of nodes that all share the same role. I know I can perform a node listing as well as a role listing of the chef server, but would like to know if I run a knife winrm against an entire role what nodes will it run against? Thank you for your time.

0 Likes

#2

perhaps I am misunderstanding your question but do you mean the results of knife search node 'role:my_rolename'?

I think you can knife winrm 'role:my_rolename' COMMAND

1 Like

#3

I need to know if there is a way to get a listing of servers thats apart of a particular role I specify. using the 'knife search node 'role:[MY_ROLENAME]' command for some reason is not returning any items found :(.

0 Likes

#4

Hmm apologies 'role:my_rolename' will only find nodes with that role in their unexpanded runlist. To find nested roles you can use the search 'roles:my_rolename' (or at least that's how it works with recipe/recipes search).

If for any reason the search returns 0 results, it will also return 0 results when included as part of a knife winrm command. You can try some wildcards and other searches to make sure it eventually returns something, like 'name:*' to list all the nodes for example.

1 Like

#5

Ok, I did get that to work just had to clean up my syntax.

Another question for you? Anyway I can isolate the output to just give me the node names?

0 Likes

#6

Okay great. Yeah I was going to mention that to get just the name use knife search node -i 'role:my_rolename'

1 Like

#7

You have made my day! Thank you so much! :smile:

1 Like