Class: VagrantPlugins::Recipe::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-recipe/command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-recipe/command.rb', line 5

def execute
  cmd, cmd_args = parse_args
  cmd && cmd_args or return nil

  # Execute the actual SSH
  with_target_vms(nil, single_target: true) do |vm|
    vm.config.recipe.finalize! # TODO: do we have to call it explicitly?

    plain   = "sudo chef-solo -c #{vm.config.recipe.chef} -j #{vm.config.recipe.json} --override-runlist \"recipe[#{cmd}]\""
    command = ""

    command << add_env(vm.config.recipe.env)
    #command << add_bundler(vm.config.recipe.bundler, plain)
    command << plain

    @logger.info("Executing recipe on remote machine: #{command}")
    env = vm.action(:ssh_run, ssh_run_command: command)

    status = env[:ssh_run_exit_status] || 0
    return status
  end
end