Class: SousChef::TaskBuilder

Inherits:
Object
  • Object
show all
Includes:
NodeHelpers, NodeTaskHelpers
Defined in:
lib/sous-chef/task_builder.rb

Instance Method Summary collapse

Methods included from NodeHelpers

node?

Methods included from NodeTaskHelpers

batch_tasks, bootstrap_task, build_node_task, clean_task, cook_task, filter_tasks, prepare_task, run, run_knife

Constructor Details

#initialize(nodes) ⇒ TaskBuilder

Returns a new instance of TaskBuilder.



5
6
7
# File 'lib/sous-chef/task_builder.rb', line 5

def initialize(nodes)
  @nodes = nodes
end

Instance Method Details

#build_batch_tasks(collection) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sous-chef/task_builder.rb', line 14

def build_batch_tasks(collection)
  collection.each do |name, collection|
    next if node?(collection)
    namespace name do |ns|
      namespace :all do
        batch_tasks(name, ns.tasks)
      end
      build_batch_tasks(collection)
    end
  end
end

#build_namespace(collection) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sous-chef/task_builder.rb', line 26

def build_namespace(collection)
  collection.each do |name, collection|
    if node?(collection)
      build_node_task(collection)
    else
      namespace name do
        build_namespace(collection)
      end
    end
  end
end

#build_tasksObject



9
10
11
12
# File 'lib/sous-chef/task_builder.rb', line 9

def build_tasks
  build_namespace(@nodes)
  build_batch_tasks(@nodes)
end