Module: OpsWorks::CLI::Subcommands::UpgradeChef

Included in:
Agent
Defined in:
lib/opsworks/cli/subcommands/upgrade_chef.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object

rubocop:disable MethodLength rubocop:disable CyclomaticComplexity



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/opsworks/cli/subcommands/upgrade_chef.rb', line 10

def self.included(thor)
  thor.class_eval do
    include Helpers::Keychain
    include Helpers::Options

    desc 'upgrade-chef [--stack STACK]', 'Upgrade Chef version'
    option :stack, type: :array
    option :version
    option :manage_berkshelf, type: :boolean, default: false
    def upgrade_chef
      fetch_keychain_credentials unless env_credentials?
      stacks = parse_stacks(options.merge(active: true))
      version = OpsWorks::Stack.latest_chef_version
      stacks.each do |stack|
        say "Upgrading #{stack.name} to #{version}..."
        stack.upgrade_chef(version, options)
      end
    end
  end
end