On 06/25/2014 11:46 PM, Nick Evgeniev wrote: > Hi, > > I need to perform (in a loop) some tasks on host 'A' till something > happens on host 'B'. What is the 'best practice' of doing such things > with ansible? > > I saw loops over single task but this is not what I need (presumably), > unless I write a shell script which perform all the tasks by > connecting to different hosts and grabs the results. As the whole > point of ansible (to me) is to pull all the ssh commands out of > scripts (and get rid of these scripts too) > -- > 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] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/cb1bea17-3025-426e-b576-408a0dafad4c%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/cb1bea17-3025-426e-b576-408a0dafad4c%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout.
Ansible playbooks have not a mechanism for repeating a part of a playbook, but this feature could be useful for your user case. For example, you could write a series of tasks and add at the end of them a 'goback' task (by creating a 'goback' action plugin) that lets you go back at the first task of that group of tasks you want to repeat. That 'goback' task would of course have the appropriate conditional, which would normally be set by the repeating tasks. - name: Task one modulename: ... - name: Task two modulename: ... - name: Task three modulename:... - name: Go back to "Task one" (so, repeat tasks one to three) goback: task="Task one" when: somecondition -- 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/53ABC4BB.8020901%40yahoo.gr. For more options, visit https://groups.google.com/d/optout.
