I want to add back up task of my databases to cron. I don’t want them to start at the same time. And I have too much hosts to initialize each of them using variables. But if I use random filter it becomes unidempotent. Is it any way how to do what I want keeping idempotency?
I've used the random filter to conditionally create either host_vars
with the value (if file exists it doesn't regenerate), optionally you
could create a file on the target in /etc/ansible/facts.d/
Another option would be to create something similar to the password
lookup, a db backed random lookup.
example (i prefer template but this makes it a 1 liner):
- copy: content="[defaults]\ntime={{60|random}}"
dest=/etc/facts.d/mycronscript.facts
when: ansible_local is not defined or 'mycronscript' in
ansible_local or 'time' not in ansible_local.mycronscripts