Bummer, this was the best solution so far! On Fri, Jan 13, 2017 at 4:41 PM, Jinesh Choksi <[email protected]> wrote:
> Ack. I just noticed that the example below is not a good solution since it > never did run the "Performing tasks after windows updates." task in the > main.yml file. > > Sorry. Please ignore the example. > > > On Friday, 13 January 2017 14:14:58 UTC, Jinesh Choksi wrote: >> >> - "until: is not currently supported on includes." ( >> https://github.com/ansible/ansible/issues/17098) >> >> - "When you call include, Ansible actually places tasks from included >> file into the execution queue after the current task." ( >> http://stackoverflow.com/a/38481496) >> >> >> The example below is a hack but it has a useful property whereby tasks in >> the inner taskbook will not be run if the play was ended. i.e. >> >> calling inner-taskbook 1st time >> - running tasks >> >> calling inner-taskbook 2nd time >> - running tasks >> >> calling inner-taskbook 3rd time >> - running tasks >> - play ended because we've determined that we've finished the work >> >> calling inner-taskbook 4th time >> - noop >> >> calling inner-taskbook 5th time >> - noop >> >> calling inner-taskbook nth time >> - noop >> >> >> So if you configure the with_sequence parameters as you would have done >> the "until:" command's "retries" attribute then you kinda simulate the >> retry functionality with the example below. >> >> You will notice that the taskbook does get "included" 100 times but the >> tasks in it are ONLY executed the number of times actually required. >> >> >> >> run.sh: >> ---snip--- >> #!/usr/bin/env bash >> >> ansible-playbook -vvv -i 'localhost,' -c local main.yml >> ---snip--- >> >> >> >> main.yml: >> >> --- >> - hosts: >> - localhost >> >> tasks: >> - name: "Performing tasks before windows updates." >> debug: msg="blah blah" >> >> - name: "Calling playbook that will install windows updates." >> include: inner-taskbook.yml >> with_sequence: start=1 end=100 >> loop_control: >> loop_var: main_item >> >> - name: "Performing tasks after windows updates." >> debug: msg="blah blah blah" >> >> >> >> inner-taskbook.yml: >> - name: "Performing Windows updates, printing loop counter for reference >> {{ main_item }}." >> debug: var=main_item >> >> - name: "Task to determine whether further updates are needed." >> set_fact: >> updates_needed: "{{ 10|random }}" >> >> - name: "Ending play if no further updates needed. {{ updates_needed }}" >> meta: end_play >> when: updates_needed == '1' >> >> >> >> -- > 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/d109f167-b52d-40f4-bc34-7c7bc9f5ffcd%40googlegroups. > com > <https://groups.google.com/d/msgid/ansible-project/d109f167-b52d-40f4-bc34-7c7bc9f5ffcd%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Danny Rehelis - autogun [AT] 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 [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/CA%2BYXgSfOAXkBSQ4Bkjn-i2mQNrTe4o8%3DSaWSvhPEGsNTHqEVCQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
