11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/vagrant-exec/command.rb', line 11
def execute
cmd, cmd_args = parse_args
cmd && cmd_args or return nil
with_target_vms(nil, single_target: true) do |vm|
constructor = CommandConstructor.new(cmd, vm.config.exec.commands)
command = constructor.construct_command
command << ' ' << cmd_args.join(' ') if cmd_args.any?
@logger.info("Executing single command on remote machine: #{command}")
ssh_opts = {extra_args: ['-q']} env = vm.action(:ssh_run, ssh_run_command: command, ssh_opts: ssh_opts)
status = env[:ssh_run_exit_status] || 0
return status
end
end
|