7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/capichef/node.rb', line 7
def self.get_attribute(node, attribute)
case attribute
when Proc
role name, attribute.call(node)
when Hash
iface, family = attribute.keys.first.to_s, attribute.values.first.to_s
addresses = node["network"]["interfaces"][iface]["addresses"]
role name, addresses.select{|address, data| data["family"] == family }.to_a.first.first
when Symbol, String
role name, node[attribute.to_s].to_s
else
raise ArgumentError, 'Attribute must be Proc, Hash, Symbol, String.'
end
end
|