Class: Itamae::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/itamae/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Runner

Returns a new instance of Runner.



84
85
86
87
88
89
90
91
# File 'lib/itamae/runner.rb', line 84

def initialize(node)
  @node = node
  @tmpdir = "/tmp/itamae_tmp"
  @children = RecipeChildren.new

  Backend.instance.run_command(["mkdir", "-p", @tmpdir])
  Backend.instance.run_command(["chmod", "777", @tmpdir])
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



82
83
84
# File 'lib/itamae/runner.rb', line 82

def children
  @children
end

#nodeObject

Returns the value of attribute node.



80
81
82
# File 'lib/itamae/runner.rb', line 80

def node
  @node
end

#tmpdirObject

Returns the value of attribute tmpdir.



81
82
83
# File 'lib/itamae/runner.rb', line 81

def tmpdir
  @tmpdir
end

Class Method Details

.run(recipe_files, backend_type, options) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/itamae/runner.rb', line 8

def run(recipe_files, backend_type, options)
  Logger.info "Starting Itamae..."

  set_backend_from_options(backend_type, options)

  runner = self.new(node_from_options(options))
  runner.load_recipes(recipe_files)
  runner.run(dry_run: options[:dry_run])
end

Instance Method Details

#load_recipes(paths) ⇒ Object



93
94
95
96
97
# File 'lib/itamae/runner.rb', line 93

def load_recipes(paths)
  paths.each do |path|
    children << Recipe.new(self, File.expand_path(path))
  end
end

#run(options) ⇒ Object



99
100
101
# File 'lib/itamae/runner.rb', line 99

def run(options)
  children.run(options)
end