Class: MCollective::Util::Playbook::Nodes::YamlNodes
- Inherits:
-
Object
- Object
- MCollective::Util::Playbook::Nodes::YamlNodes
- Defined in:
- lib/mcollective/util/playbook/nodes/yaml_nodes.rb
Instance Method Summary collapse
- #data ⇒ Object
-
#discover ⇒ Object
Performs the PQL query and extracts certnames.
-
#from_hash(data) ⇒ PqlNodes
Initialize the nodes source from a hash.
-
#initialize ⇒ YamlNodes
constructor
A new instance of YamlNodes.
- #prepare ⇒ Object
- #validate_configuration! ⇒ Object
Constructor Details
#initialize ⇒ YamlNodes
Returns a new instance of YamlNodes.
8 9 10 11 |
# File 'lib/mcollective/util/playbook/nodes/yaml_nodes.rb', line 8 def initialize @group = nil @file = nil end |
Instance Method Details
#data ⇒ Object
35 36 37 |
# File 'lib/mcollective/util/playbook/nodes/yaml_nodes.rb', line 35 def data @_data ||= YAML.safe_load(File.read(@file)) end |
#discover ⇒ Object
Performs the PQL query and extracts certnames
40 41 42 |
# File 'lib/mcollective/util/playbook/nodes/yaml_nodes.rb', line 40 def discover data[@group] end |
#from_hash(data) ⇒ PqlNodes
Initialize the nodes source from a hash
28 29 30 31 32 33 |
# File 'lib/mcollective/util/playbook/nodes/yaml_nodes.rb', line 28 def from_hash(data) @group = data["group"] @file = data["source"] self end |
#prepare ⇒ Object
13 |
# File 'lib/mcollective/util/playbook/nodes/yaml_nodes.rb', line 13 def prepare; end |
#validate_configuration! ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/mcollective/util/playbook/nodes/yaml_nodes.rb', line 15 def validate_configuration! raise("No node group YAML source file specified") unless @file raise("Node group YAML source file %s is not readable" % @file) unless File.readable?(@file) raise("No node group name specified") unless @group raise("No data group %s defined in the data file %s" % [@group, @file]) unless data.include?(@group) raise("Data group %s is not an array" % @group) unless data[@group].is_a?(Array) raise("Data group %s is empty" % @group) if data[@group].empty? end |