dev-group1
hostA
hostB
tst-group1
hostC
hostD
pre-group1
hostE
hostF
pro-group1
hostG
hostH
dev-group2
hostI
hostJ
tst-group2
hostK
hostL
and so on...
/backup/dev-group1/
/backup/tst-group1/
etc...
$ ansible-playbook fetch_from_server.yml -sK --extra-vars "@fetch_loop_vars.yml" -v
---
file: '/root/.bash_profile'
my_groups: ['0dm-sap', 'dev-sap', 'tst-sap', 'pre-sap', 'pro-sap']
---
- 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}}
ok: [hostA] => {"changed": false, "dest": "/backup/[dev-group1,/hostA/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostB] => {"changed": false, "dest": "/backup/[dev-group1,/hostB/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostD] => {"changed": false, "dest": "/backup/[dev-group1,/hostC/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostC] => {"changed": false, "dest": "/backup/[dev-group1,/hostD/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostA] => {"changed": false, "dest": "/backup/dev-group1/hostA/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostB] => {"changed": false, "dest": "/backup/dev-group1/hostB/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostD] => {"changed": false, "dest": "/backup/tst-group1/hostC/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
ok: [hostC] => {"changed": false, "dest": "/backup/tst-group1/hostD/root/.bash_profile", "file": "/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078"}
changed: [hostA] => {"changed": true, "dest": "/backup/0dm-sap:dev-sap:tst-sap:pre-sap:pro-sap/hostA/hostA/root/.bash_profile", "md5sum": "bab9333347e752b87add49020919a078", "remote_md5sum": "bab9333347e752b87add49020919a078"}
you can try just rewriting my_groups this way:my_groups: "0dm-sap:dev-sap:tst-sap:pre-sap:pro-sap"
--To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADn%2BHsycxjO%2B3RNXMgr87f-8MiMJcTvstymiQe%2Buy5Ybsw81Nw%40mail.gmail.com.
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/73e4e65b-e10e-45f0-a7df-0bfe4423aa78%40googlegroups.com.