Sha256: bc89b3e2740edccbfbffffd99ad9df7d11916c1e3e77a8ad68f0ea9db001741b

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module OpsWorks
  module CLI
    module Subcommands
      module Exec
        # rubocop:disable MethodLength
        # rubocop:disable CyclomaticComplexity
        def self.included(thor)
          thor.class_eval do
            desc 'exec [--stack STACK] RECIPE', 'Execute a Chef recipe'
            option :stack, type: :array
            def exec(recipe)
              fetch_keychain_credentials unless env_credentials?
              stacks = parse_stacks(options)
              deployments = stacks.map do |stack|
                say "Executing recipe on #{stack.name}..."
                stack.execute_recipe(recipe)
              end
              Deployment.wait(deployments)
              unless deployments.all?(&:success?)
                failures = []
                deployments.each_with_index do |deployment, i|
                  failures << stacks[i].name if deployment.failed?
                end
                fail "Command failed on #{failures.join(', ')}"
              end
            end
          end
        end
        # rubocop:enable CyclomaticComplexity
        # rubocop:enable MethodLength
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opsworks-cli-0.2.0 lib/opsworks/cli/subcommands/exec.rb