At 2014-05-22 05:21:35 -0700, [email protected] wrote:
>
> fetch_loop_vars.yml looks like this:
> ---
> file: '/root/.bash_profile'
> my_groups: ['0dm-sap', 'dev-sap', 'tst-sap', 'pre-sap', 'pro-sap']
> 
> And my fetch_from_server.yml is this:
> ---
> - hosts: '{{my_groups}}'
>   sudo: True
>   gather_facts: no
>   tasks:
>     - name: fetch the file from the server
>       fetch: src={{file}} dest=/backup/{{my_groups}}/{{inventory_hostname}}

This task isn't actually using a loop in the Ansible sense. You need to
provide a list to iterate over using with_items: or similar. For a more
detailed explanation, see http://docs.ansible.com/playbooks_loops.html
(it has lots of examples).

That said, I don't know the best way to iterate over the hosts in a
subset of all your groups in quite the way you describe. Perhaps the
examples on the following page will prove helpful:

http://docs.ansible.com/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts

-- ams

-- 
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/20140522124003.GC17698%40toroid.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to