Writing an endless playbook strategy plugin

101 views
Skip to first unread message

Florian Dambrine

unread,
Nov 16, 2016, 8:22:32 AM11/16/16
to Ansible Project
Hey everyone,

I would like to have your input on that question.

I have a really special use case where I want to run an endless playbook (on localhost only). I basically want to implement an endless loop on my playbook. As we all know, looping over a set of tasks or blocks is not possible with a statement like while true, which will look like:

### role/tasks/main.yml
---

- include: run-in-loop.yml
 
until: False

Right now looping over includes is doable by doing a with_ statement. What I trying to achieve right now would look like:

### role/tasks/main.yml
---

- include: run-in-loop.yml
  with_sequence: start=0 end=<+INFINITE>
  loop_control:
    loop_var: main_item



This might not be a good idea at all, as I have no idea how Ansible will consume resources on the server (Memory especially).

I can of course use a higher level command that will keep triggering my playbook in a loop, but I was actually thinking about implementing a custom strategy called endless for example. 

This strategy will be based on the classic linear strategy. 

Is that a really really bad idea or you think that could be doable?

Thanks in advance for your thoughts!

Benjamin Redling

unread,
Nov 16, 2016, 8:33:08 AM11/16/16
to ansible...@googlegroups.com
On 11/16/2016 14:22, Florian Dambrine wrote:
> [...] I basically want to implement an endless loop on my
> playbook.
[...]
> I can of course use a higher level command that will keep triggering my
> playbook in a loop, but I was actually thinking about implementing a
> _custom strategy_ called *endless *for example.

I don't understand the "but": what do you *gain* by implementing your
own strategy apart from learning to implement your own custom strategy?

No (ana)cron(-alike) available?

Cheers,
Benjamin
--
FSU Jena | JULIELab.de/Staff/Benjamin+Redling.html
vox: +49 3641 9 44323 | fax: +49 3641 9 44321

Florian Dambrine

unread,
Nov 16, 2016, 8:42:21 AM11/16/16
to Ansible Project
Well in my case I wont even need a cron-alike tool... I just want to start the playbook once and keep it running all the time. Maybe something like supervisor could help me keeping that playbook running all the time.

Brian Coca

unread,
Nov 16, 2016, 4:25:03 PM11/16/16
to ansible...@googlegroups.com
I would just setup a daemontools service or if using systemd a unit that continually restarts ansible-playbook every time it dies

----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages