Can I throttle a task with delay?

16 views
Skip to first unread message

tterr...@gmail.com

unread,
Sep 11, 2020, 4:50:08 AM9/11/20
to Ansible Project
I have an inventory containing a few dozens hosts.

I have a short playbook that configures a monitoring service on a single server. I build the contents of a per host config for the monitoring service and then I upload it to the monitoring service and restart the service in order for it to read the new config. This means that all tasks run against each host (as normal) except the last two that are delegated to the monitoring server (upload and restart).

The issue is that systemd complains if there are too many restarts. I have managed to solve this by raising the number of permitted restarts per second in systemd. But, still, restarts may run too fast that systemd will run up to 5 restarts in parallel (I am using the linear strategy with default forks). For this reason, I set throttle to 1 for this task. However, still, subsequent restarts may run too fast in sequence that they somehow overlap and systemd errors out.

My question is if there is a way to have throttle with a delay among hosts. I considered creating a block that contains the systemd-restart tasks plus a sleep  tasks and set throttle there. But I was looking for sth more elegant at the task level.

Stefan Hornburg (Racke)

unread,
Sep 11, 2020, 4:56:26 AM9/11/20
to ansible...@googlegroups.com
I would use a Ansible handler that restarts the monitoring service after all changes are complete.
Doesn't make sense to me to restart it after each upload.

Reference:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#handlers-running-operations-on-change

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/c509af8a-5520-443d-aaf5-f0874f9f062fn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c509af8a-5520-443d-aaf5-f0874f9f062fn%40googlegroups.com?utm_medium=email&utm_source=footer>.


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

signature.asc

tterr...@gmail.com

unread,
Sep 11, 2020, 6:55:37 AM9/11/20
to Ansible Project
Yes, handlers make sense. But what if I want to make requests that have a rate limit, e.g 1req / sec?
Reply all
Reply to author
Forward
0 new messages