Reputation: 98
I started writing a plugin for Vagrant, which will add a command. Within the Command#execute I need to capture the :ssh_run output. Right now output goes straight to stdout. Small test snippet from the command:
with_target_vms(@argv, single_target: true) do |vm|
vm.action(:ssh_run, ssh_run_command: 'tail -50 /var/log/boot.log')
end
Has anyone an idea how to do it? Maybe vm.action itself isn't the right way?
Thanks a lot in advance
Sebastian
Upvotes: 0
Views: 218
Reputation: 98
That was fast. @effhaa told me the on another channel.
with_target_vms(@argv, single_target: true) do |vm|
result = []
vm.communicate.sudo('tail -50 /var/log/boot.log') do |type, data|
if type == :stdout
result = data.split(/[\r\n]+/)
end
end
end
Upvotes: 1