Get node names that have a specific role

chefknife

How can I get list of nodes, that have a specific role?

It could be got with something like that:

for node in `knife node list`; do
  [[ -n "`knife node show $node | grep $ROLE_NAME`" ]] &&  echo $node
done

Is there a way to doing it via knife without bash overhead?

Best Answer

There is a solution:

knife search node "roles:$ROLE_NAME"