# playbook configuring cron job help

**URL:** <https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212>\
**Category:** Ansible Project\
**Created:** [July 29, 2013, 10:58am UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212 "2013-07-29T10:58:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [July 29, 2013, 10:58am UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/1 "2013-07-29T10:58:53Z")

</div>

Hi,

I’m experimenting with ansible to replace puppet, but i’m very new to it and getting a little stuck with setting up a cron job

i have a yaml file like this

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 29, 2013, 1:51pm UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/2 "2013-07-29T13:51:05Z")

</div>

Hi!

The cron module in 1.2.X had some minor issues, which is much improved in 1.3 code.

If you would like to try 1.3, it’s releasing soon (in about a month) and is quite stable. Just do a git checkout and source ./hacking/env-setup

Alternatively, you could just template the cron file with the template module, or, as I usually do, use the template module to a cron.d file.

–Michael

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [July 29, 2013, 2:35pm UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/3 "2013-07-29T14:35:35Z")

</div>

Hello,

thanks for getting back to me.

I’m running 1.3 and just found the test/cron\_test.yml file and that comes back with the same error as my attempt when i try and run it.

thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 29, 2013, 2:50pm UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/4 "2013-07-29T14:50:06Z")

</div>

can you please show me the specific task that failed and the playbook output for that task?

Thanks!

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [July 29, 2013, 3:14pm UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/5 "2013-07-29T15:14:24Z")

</div>

Here you go,

ansible-playbook cron\_test.yml

PLAY [malweb01] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [test 1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [malweb01] =\> {“failed”: true, “parsed”: false}  
invalid output was: File “/home/sgoodliff/.ansible/tmp/ansible-1375110498.1-32714460096252/cron”, line 186  
except IOError as e:  
^  
SyntaxError: invalid syntax

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/var/tmp/ansible/cron\_test.retry

malweb01 : ok=0 changed=0 unreachable=0 failed=1

from test/cron\_test.yml

tasks:

- name: test 1  
cron: name=“execution test 1” weekday=“2,3” minute=0 hour=12 user=“sgoodliff” job=“YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate” cron\_file=yum-autoupdate state=absent  
tags:
- cron

Also for example

Perform task: test 2-3 (y/n/c): \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [malweb01] =\> {“failed”: true, “parsed”: false}  
invalid output was: File “/home/sgoodliff/.ansible/tmp/ansible-1375110798.84-257369986353663/cron”, line 186  
except IOError as e:  
^  
SyntaxError: invalid syntax

Thanks again

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 29, 2013, 5:28pm UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/6 "2013-07-29T17:28:09Z")

</div>

Ah, this is a python 2.4 compliance issue.

It should say except IOError, e:

in the code, I’ll fix it ASAP.

Thanks for catching this!

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [July 30, 2013, 7:48am UTC](https://forum.ansible.com/t/playbook-configuring-cron-job-help/13212/7 "2013-07-30T07:48:07Z")

</div>

hi,

its working fine for me now

cheers
