Class: MotherBrain::Bootstrap::Routine
- Inherits:
-
Object
- Object
- MotherBrain::Bootstrap::Routine
- Defined in:
- lib/mb/bootstrap/routine.rb
Defined Under Namespace
Instance Attribute Summary collapse
- #plugin ⇒ MB::Plugin readonly
Class Method Summary collapse
-
.map_instructions(tasks, manifest) ⇒ Hash
Takes a task, or array of tasks, and a Bootstrap::Manifest and returns a Hash containing instructions for how to bootstrap each node found in the manifest based on the set of tasks, or task, given.
Instance Method Summary collapse
-
#has_task?(node_group, task_queue = self.task_queue) ⇒ Boolean
Checks if the routine contains a boot task for the given node group.
-
#initialize(plugin, &block) ⇒ Routine
constructor
A new instance of Routine.
-
#task_queue ⇒ Array<Bootstrap::Routine::Task>+
Returns an array of groups or an array of an array groups representing the order in which the cluster should be bootstrapped in.
Constructor Details
#initialize(plugin, &block) ⇒ Routine
Returns a new instance of Routine.
113 114 115 116 117 118 119 120 |
# File 'lib/mb/bootstrap/routine.rb', line 113 def initialize(plugin, &block) @plugin = plugin @task_procs = Array.new if block_given? dsl_eval(&block) end end |
Instance Attribute Details
#plugin ⇒ MB::Plugin (readonly)
110 111 112 |
# File 'lib/mb/bootstrap/routine.rb', line 110 def plugin @plugin end |
Class Method Details
.map_instructions(tasks, manifest) ⇒ Hash
Takes a task, or array of tasks, and a Bootstrap::Manifest and returns a Hash containing instructions for how to bootstrap each node found in the manifest based on the set of tasks, or task, given.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/mb/bootstrap/routine.rb', line 87 def map_instructions(tasks, manifest) {}.tap do |nodes| Array(tasks).each do |task| manifest.hosts_for_group(task.group_name).each do |host| nodes[host] ||= { groups: Array.new, options: { run_list: Array.new, chef_attributes: Hashie::Mash.new } } nodes[host][:groups] << task.group_name unless nodes[host][:groups].include?(task.group_name) nodes[host][:options][:run_list] = nodes[host][:options][:run_list] | task.run_list nodes[host][:options][:chef_attributes] = nodes[host][:options][:chef_attributes].deep_merge(task.chef_attributes) end end end end |
Instance Method Details
#has_task?(node_group, task_queue = self.task_queue) ⇒ Boolean
Checks if the routine contains a boot task for the given node group
138 139 140 141 142 143 144 145 146 |
# File 'lib/mb/bootstrap/routine.rb', line 138 def has_task?(node_group, task_queue = self.task_queue) task_queue.find do |task| if task.is_a?(Array) has_task?(node_group, task) else task.group_name == node_group end end end |
#task_queue ⇒ Array<Bootstrap::Routine::Task>+
Returns an array of groups or an array of an array groups representing the order in which the cluster should be bootstrapped in. Groups which can be bootstrapped together are contained within an array. Groups should be bootstrapped starting from index 0 of the returned array.
128 129 130 |
# File 'lib/mb/bootstrap/routine.rb', line 128 def task_queue @task_queue ||= MB.(task_procs) end |