playbook configuring cron job help

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

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

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

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

Thanks!

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

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!

hi,

its working fine for me now

cheers