Class: Hazetug::Task
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #hosts_to_bootstrap(cmd_vars = {}, &block) ⇒ Object
-
#initialize(path) ⇒ Task
constructor
A new instance of Task.
Methods included from UI::Mixin
Constructor Details
#initialize(path) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hazetug/task.rb', line 10 def initialize(path) path = File.(path) @task = Mash.new(Psych.load_file(path)) rescue Psych::Exception ui.fatal "Unable to parse hazetug task file: '#{path}'" puts $!.inspect, $@ exit(1) rescue SystemCallError ui.fatal "Unable to read file: '#{path}'" exit(1) end |
Class Method Details
.[](key) ⇒ Object
44 45 46 |
# File 'lib/hazetug/task.rb', line 44 def [](key) @instance and @instance[key] end |
.load_from_file(path) ⇒ Object
40 41 42 |
# File 'lib/hazetug/task.rb', line 40 def load_from_file(path) @instance ||= self.new(path) end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 |
# File 'lib/hazetug/task.rb', line 22 def [](key) @task[key] end |
#hosts_to_bootstrap(cmd_vars = {}, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hazetug/task.rb', line 26 def hosts_to_bootstrap(cmd_vars={}, &block) return if block.nil? base_conf = Mash.new(task) hosts = base_conf.delete(:bootstrap) base_conf = Chef::Mixin::DeepMerge.merge(base_conf, cmd_vars) hosts.each do |conf| merged = Chef::Mixin::DeepMerge.merge(base_conf, conf) block.call(merged) end end |