On Fri, 30 Aug 2019 01:22:08 -0700 (PDT) Mohtashim S <[email protected]> wrote:
> How to pass "stdout" of a variable "command_result" belonging to Ansible
> Play-1 to shell module of a different Play-2?
>
> My playbook looks like below:
>
> - name: Play 1
> hosts: localhost
> tasks:
> - name: "Collect Output"
> command: ls -ltr *
> register: command_result
- set_fact:
command_result: "{{ command_result }}"
> - name: Play 2
> hosts: remotehost
> tasks:
> - shell: "~/rollback.sh {{ Number }} '{{ InstallDir }}' '{{
> hostvars[\"localhost\"][\"command_result\"].results|map(attribute=/'stdout/')|list
>
> }}' > ~/rollback.log"
Make the scope of "command_result" playbook-wide with "set_fact". Registered
variables belong to the host which is running the play. i.e. "localhost" in
your case. The second play runs "remotehost" who know nothing about varaibles
registered by "localhost".
Cheers,
-vlado
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20190830103311.63815fba%40gmail.com.
pgpSZ3o3o9fQp.pgp
Description: OpenPGP digital signature
