Roles Loop

23 views
Skip to first unread message

blue fox

unread,
Nov 23, 2020, 7:19:37 AM11/23/20
to Ansible Project
I like to make a loop for a role , each time he copie each host in file

example:
------------------
hosts file

webserver]

10.10.10.10

20.20.20.20

---------------------
turn 1 for loop: copie   10.10.10.10.  in file and send it to distant server

turn 2 for loop: copie   20.20.20.20.  in file and send it to distant server

Thank you

Stefan Hornburg (Racke)

unread,
Nov 23, 2020, 7:32:38 AM11/23/20
to ansible...@googlegroups.com
So you want to execute the role only for members of webserver group?

If so you can add the following condition:

when: "'webserver' in group_names"

Regards
Racke

>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/01483a96-5a98-42d7-ac0b-aed2a60d4593n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/01483a96-5a98-42d7-ac0b-aed2a60d4593n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

OpenPGP_signature

blue fox

unread,
Nov 23, 2020, 8:36:21 AM11/23/20
to Ansible Project

i want to copy each host in webservers group in file and send it to ather server distant.

each role execute ---- > copy one host in file 

thank you

Stefan Hornburg (Racke)

unread,
Nov 23, 2020, 8:47:21 AM11/23/20
to ansible...@googlegroups.com
On 11/23/20 2:36 PM, blue fox wrote:
>
> i want to copy each host in webservers group in file and send it to ather server distant.
>
> each role execute ---- > copy one host in file

It is not clear to me what you want to achieve. How does your role look like?

Regards
Racke
> <https://groups.google.com/d/msgid/ansible-project/01483a96-5a98-42d7-ac0b-aed2a60d4593n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/01483a96-5a98-42d7-ac0b-aed2a60d4593n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8cbe7244-35a3-42d2-a508-14c6b708e887n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8cbe7244-35a3-42d2-a508-14c6b708e887n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_signature

blue fox

unread,
Nov 23, 2020, 8:55:15 AM11/23/20
to Ansible Project
i need to test each time each ip address alone in another server, therefore i need to copy each ip address in webservers group in file and sen this file to server distant for test it 
the test treatment = role

1- copy the primary ip and send the file in testing server
2- execute roles for testing
3- copy the seconde in the same file ip and send it in testing server
4- execute the same role for testing

Thank you
Reply all
Reply to author
Forward
0 new messages