Module: Bebox::ProvisionCommands

Defined in:
lib/bebox/commands/provision_commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



5
6
7
# File 'lib/bebox/commands/provision_commands.rb', line 5

def self.extended(base)
  base.load_commands
end

Instance Method Details

#apply(environment, args) ⇒ Object



34
35
36
37
38
39
# File 'lib/bebox/commands/provision_commands.rb', line 34

def apply(environment, args)
  step = args.first
  help_now!(error('You did not specify an step')) if args.count == 0
  help_now!(error('You did not specify a valid step')) unless Bebox::CommandsHelper.valid_step?(step)
  Bebox::ProvisionWizard.new.apply_step(project_root, environment, step)
end

#apply_all(environment) ⇒ Object



27
28
29
30
31
32
# File 'lib/bebox/commands/provision_commands.rb', line 27

def apply_all(environment)
  title "Provisioning all steps..."
  Bebox::PROVISION_STEPS.each do |step|
    Bebox::ProvisionWizard.new.apply_step(project_root, environment, step)
  end
end

#load_commandsObject



9
10
11
# File 'lib/bebox/commands/provision_commands.rb', line 9

def load_commands
  load_provision_commands
end

#load_provision_commandsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bebox/commands/provision_commands.rb', line 13

def load_provision_commands
  desc 'Apply the Puppet step for the nodes in a environment. (step-0: Fundamental, step-1: User layer, step-2: Service layer, step-3: Security layer)'
  arg_name "[step]"
  command :apply do |apply_command|
    apply_command.switch :all, :desc => 'Apply all steps in sequence.', :negatable => false
    apply_command.flag :environment, :desc => 'Set the environment of nodes', default_value: default_environment
    apply_command.action do |global_options,options,args|
      environment = get_environment(options)
      title "Environment: #{environment}"
      options[:all] ? apply_all(environment) : apply(environment, args)
    end
  end
end