Method: Chef::Node#allies
- Defined in:
- lib/chef-helpers/node.rb
#allies ⇒ Array<Chef::Node>
Node's "allies" are all nodes in the same environment (if the
environment is not _default
), and nodes specified by allies
attribute. The allies
attribute - if set - should be an array of
node names or node search queries; the named nodes and search
results will be added to node's allies.
This is mostly useful when defining firewall or other access rules, to easily limit access to insides of a cluster plus a handful of friendly machines.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chef-helpers/node.rb', line 17 def allies @allies ||= begin rv = [] q = Chef::Search::Query.new rv += q.search(:node, "chef_environment:#{self.chef_environment}").first unless self.chef_environment == '_default' if self['allies'] self['allies'].each do |ally| ally = "name:#{ally}" unless ally.include?(':') rv += q.search(:node, ally).first end end rv end end |