Could you perhaps save the results into different files on the local
machine (such as /tmp/local_action.{{ inventory_hostname }}), then assemble
them into a single file as a subsequent task? There is an assemble module
<http://docs.ansible.com/assemble_module.html> that may do the job.
​

On 18 January 2015 at 04:04, Jim McMahon <[email protected]>
wrote:

> I'm trying to run a shell command on multiple servers and have the results
> appended to a local file.  The way I have it written now doesn't work.  I
> only get the result of the last server because it runs the first task for
> each server before moving on to the next task. Hence I get the result of
> the last server in my file.
>
> How do I get this to work with Ansible?  The example here:
> http://docs.ansible.com/playbooks_loops.html doesn't really fit my
> situation because I want the loop to be on inventory hosts.
>
>
> ---
>
> - name: get metadata on legacy servers
>   shell: >
>     hostname; len=`hostname | wc -c` ; export len; perl -E 'say "=" x
> ($ENV{"len"} - 1)' ;
>     ec2-metadata -i -a -z -s -v
>   register: result
>   tags:
>     - legacy
>
> - name: copy results to local file
>   local_action: copy >
>     content="{{ result.stdout }}"
>     dest="/tmp/local_action"
>   tags:
>     - legacy
>
> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f980940c-bf3f-416f-896a-d258519e2d6d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f980940c-bf3f-416f-896a-d258519e2d6d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAnNz0MT3eEC_viDxYTyPc9Bboe1xQbFNF%3DJRvbj2zWOc2yBtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to