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.



77
78
79
80
81
82
83
84
# File 'lib/itamae/runner.rb', line 77

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.



75
76
77
# File 'lib/itamae/runner.rb', line 75

def children
  @children
end

#nodeObject

Returns the value of attribute node.



73
74
75
# File 'lib/itamae/runner.rb', line 73

def node
  @node
end

#tmpdirObject

Returns the value of attribute tmpdir.



74
75
76
# File 'lib/itamae/runner.rb', line 74

def tmpdir
  @tmpdir
end

Class Method Details

.run(recipe_files, backend_type, options) ⇒ Object



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

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



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

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

#run(options) ⇒ Object



92
93
94
# File 'lib/itamae/runner.rb', line 92

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