Sha256: a797242a625b92963011185fc29e70b51a26374ed4bfcf4bc6a854be9b67b551

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require "opsicle/deploy_helper"

module Opsicle
  class ExecuteRecipes
    include DeployHelper
    attr_reader :client, :recipes

    def initialize(environment)
      @environment = environment
      @client = Client.new(environment)
    end

    def execute(options={ monitor: true })
      Output.say "Starting OpsWorks chef run..."

      #so this is how to format the command arguments:
      #http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/OpsWorks/Client.html#create_deployment-instance_method
      command_args = {}
      command_args["recipes"] = options[:recipes]
      command_opts = {}
      command_opts["instance_ids"] = determine_instance_ids(options) if options[:instance_ids] || options[:layers]

      response = client.run_command('execute_recipes', command_args, command_opts)
      launch_stack_monitor(response, options)
    end
      
    def determine_instance_ids(options)
      if options[:instance_ids]
        options[:instance_ids]
      elsif options[:layers]
        Opsicle::Layer.instance_ids(client, options[:layers])
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opsicle-0.7.1 lib/opsicle/commands/execute_recipes.rb
opsicle-0.7.0 lib/opsicle/commands/execute_recipes.rb
opsicle-0.6.0 lib/opsicle/commands/execute_recipes.rb