Alex Khvatov
Alex Khvatov

Reputation: 1485

Is there a way to get a list of nodes belonging to a role

Is there a way to get a list of nodes (and their IPs for example) that have been assigned to a role?

Upvotes: 1

Views: 1195

Answers (2)

bok
bok

Reputation: 9

Chef allows you to search all nodes that have a role. Example below

search(:node, 'role:myrole').each do |all_nodes_with_myrole|
  # code here
end

Upvotes: 0

Javier Segura
Javier Segura

Reputation: 668

As pointed by sethvargo, if you are using Chef Server you could use the knife search in your terminal

$ knife search 'role:myrolename'

Upvotes: 1

Related Questions