How to remember state?

29 views
Skip to first unread message

Hilco Wijbenga

unread,
Sep 17, 2014, 11:37:56 AM9/17/14
to Ansible Project
Hi all,

Let's say we have a role-a with two tasks: task-1 and task-2. Task-2
only runs if task-1 has triggered a change. So far, so good. But what
happens when task-2 fails? If we rerun role-a then task-1 will not
trigger a change so task-2 will not run. But we still need it to run.

Is there a way to "remember" the fact that task-2 should run? The best
I can come up with is to create a task-2-must-run empty marker file
somewhere when task-1 triggers a change [and assume that creating said
file will never fail :-) ]. Then have task-2 trigger on the existence
of the marker file.

That seems possible but rather convoluted. Thoughts?

Cheers,
Hilco

James Cammarata

unread,
Sep 17, 2014, 1:31:09 PM9/17/14
to ansible...@googlegroups.com
Hi Hilco, you can use the --start-at-task option to start execution of a playbook at a given task. The --step option can also be used, which asks if you wish to skip each task in the playbook (you can give it an answer to stop prompting and just run as well).

I am just now noticing that there doesn't appear to be any documentation regarding these options on our docs site, so I'll create a github issue for that as well. 

Finally, when a task fails, a "retry" file is created, which you can use to re-execute on hosts which have failed.

Thanks!


--
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/CAE1pOi1cqm53-c5-hMaQFWhLt%3DipMpnZ_sufm%3DNSUL8igj%3Diog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages