Is there a way to guarantee idempotency for players using randomly generated variables?
For example, I want to configure my crontabs to run emails on multiple servers at different times, so I create random integers using one set_fact module:
tasks: - set_fact: first_run_30="{{ 30 | random }}" run_once: yes
Then apply these generated variables to my crontab using these features:
- name: Setup cron30job cron: name=cron30job minute={{first_run_30}},{{first_run_30 | int + 30}} job='/bin/bash /cron30job.sh' state=present user=root environment: MAILTO: ' me@somelist.com ' MAILFROM: ' me@somehost.com '
This works very well, however, in my opinion, this principle of unacceptable purity is violated using this strategy, because every time a game occurs, you see a change:
TASK: [Setup cron30job] ***************************************** changed: [127.0.0.1]
In addition, in crontab checking as root each time for three separate runs:
[ansible]# cat /var/spool/cron/root #Ansible: cron30job 5,35 * * * * /bin/bash /sw/test/cron30job.sh #Ansible: cron30job 9,39 * * * * /bin/bash /sw/test/cron30job.sh #Ansible: cron30job 6,36 * * * * /bin/bash /sw/test/cron30job.sh
If there is a workaround, or perhaps in my scenario it may be irreversibly implausible, I would like to know.
source share