Reputation: 529
How can I pipe the stdout
of a command executed on the host (admin) machine to the stdin
of a process on the target (remote) machine, using a playbook?
To illustrate, imagine I wanted to do the following via Ansible instead of ssh
(echo
and dd
are arbitrary placeholders for the actual scripts)
echo hello world | ssh remote 'dd of=message.txt'
Upvotes: 3
Views: 1808
Reputation: 529
Using the following task composition:
- command: '<remote command>'
args:
stdin: "{{ lookup('pipe','<local command>') }}"
For example:
- command: 'dd of=message.txt'
args:
stdin: "{{ lookup('pipe','echo hello world') }}"
References:
Upvotes: 3