Method: Opsup::App#run

Defined in:
lib/opsup/app.rb

#run(commands, config) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/opsup/app.rb', line 35

def run(commands, config)
  validate_commands(commands)
  @logger.warn('Started in DRYRUN MODE') if config.dryrun
  @logger.debug("Running #{commands} with #{config.to_h}")

  opsworks = new_opsworks_client(config)
  stack_operator = Opsup::StackOperator.create(opsworks: opsworks)
  deployer = stack_operator.new_deployer(
    stack_name: config.stack_name,
    mode: config.running_mode,
    dryrun: config.dryrun,
  )

  commands.each do |command|
    if command == 'upload_cookbooks'
      upload_cookbooks(config)
      next
    end
    deployer.run_command(command_to_opsworks_command(command))
  end
ensure
  @logger.warn('Finished in DRYRUN MODE') if config.dryrun
end