Class: VagrantPuppetconf::Command::Puppetenv

Inherits:
Vagrant::Command::Base
  • Object
show all
Defined in:
lib/vagrant-puppetconf/command/puppetenv.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vagrant-puppetconf/command/puppetenv.rb', line 17

def execute
  @ui = Vagrant::UI::Colored.new('puppetconf')
  options = {}

  argv = parse_options OptionParser.new
  args = split_main_and_subcommand argv

  vms = args[0]
  options[:environment] = args[1]

  validate options

  with_target_vms(vms) do |vm|
    Updater.update(vm, @ui, {'main/environment' => options[:environment]})
  end
end

#validate(options) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/vagrant-puppetconf/command/puppetenv.rb', line 7

def validate(options)
  %w{environment}.each do |opt|
    if options[opt.to_sym].nil? || options[opt.to_sym].empty?
      @ui.error "#{opt.upcase} not set"
      @ui.info "Usage: vagrant [vm-name] puppetenv #{I18n.t('vagrant.plugins.puppetconf.command.options.environment')}"
      exit 1
    end
  end
end