I have a playbook that has 2 cron tasks that run back-to-back for the same user:
`
This puts MAILTO at the top of the crontab.
-
name: “transfers crontab setup”
cron: name=“MAILTO section” minute=“MAILTO = [email address redacted from this post]” hour= day= month= weekday= job= user=“transfers”
tags: -
duply
-
name: cron to run duply backup
cron: hour=1 minute=0 job=“duply apache_logs backup >> /var/log/duply” user=“transfers”
tags: -
duply
`
Note that this playbook uses ‘include’ to place it in the tasks list of another top-level playbook. When I run the top-level playbook, the two cron tasks run properly. Running the top-level playbook a second time, the first cron indicates that no change is needed, but the second cron indicates a change and adds a duplicate pair of lines in the crontab like this:
`
$ crontab -l
#Ansible: MAILTO section
MAILTO = [email address redacted from this post]
#Ansible: None
0 1 * * * duply apache_logs backup >> /var/log/duply
#Ansible: None
0 1 * * * duply apache_logs backup >> /var/log/duply
`
Here is the output generated for these 2 tasks for the second run:
`
TASK [transfers crontab setup] *************************************************
ok: [portia] => {“changed”: false, “envs”: , “jobs”: [“MAILTO section”, “None”]}
TASK [cron to run duply backup] ************************************************
changed: [portia] => {“changed”: true, “envs”: , “jobs”: [“MAILTO section”, “None”, “None”]}
`
If I run the top-level playbook again, a third pair of lines is added for duply. The same happens for the fourth, fifth, etc. times, adding more duplicate pairs. This is definitely not idempotent.
Here is the output for some other commands:
`
$ ansible-playbook --version
ansible-playbook 2.1.1.0
[removed config lines]
$ cat /etc/issue
Ubuntu 14.04.3 LTS \n \l
`