Module: Ey::Core::Cli::Helpers::Chef

Included in:
Recipes::Apply, Recipes::Upload
Defined in:
lib/ey-core/cli/helpers/chef.rb

Instance Method Summary collapse

Instance Method Details

#run_chef(type, environment) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ey-core/cli/helpers/chef.rb', line 8

def run_chef(type, environment)
  request = environment.apply(type)
  puts "Started #{type} chef run".green
  request.wait_for { |r| r.ready? }
  if request.successful
    puts "#{type.capitalize} chef run completed".green
  else
    puts "#{type.capitalize} chef run failed".red
    ap request
  end
end

#upload_recipes(environment, path = "cookbooks/") ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ey-core/cli/helpers/chef.rb', line 20

def upload_recipes(environment, path="cookbooks/")
  recipes_path = Pathname.new(path)

  if recipes_path.exist? && recipes_path.to_s.match(/\.(tgz|tar\.gz)/)
    environment.upload_recipes(recipes_path)
  elsif recipes_path.exist?
    environment.upload_recipes(archive_directory(path))
  else
    raise RecipesNotFound, "Recipes file not found: #{recipes_path}"
  end
end