Ability to create working cronjobs

I want to configure cronjobs on different servers at the same time for Data Mining. I also already followed the Ansible and crontabs steps, but so far nothing has worked. Whatever I do, I get an error message:

ERROR: cron is not a legal parameter at this level in an Ansible Playbook 

I have: Ansible 1.8.1

And for some unknown reason, my modules are located in: /usr/lib/python2.6/site-packages/ansible/modules/

I would like to know exactly what steps I must follow so that Ansible installs a new cronjob in the crontab file.

  • What exactly should the tutorial for installing cronjob look like?
  • What is the command line to run this play?

I ask this strange question because cron documentation is not enough and the examples do not work. Perhaps my installation is incorrect, and I want to test it with a working cron example.

+7
cron ansible
source share
2 answers

I have (something very similar) in a file. /roles/cron/tasks/main.yml:

 - name: Creates weekly backup cronjob cron: minute="20" hour="5" weekday="sun" name="Backup mysql tables (weekly schedule)" cron_file="mysqlbackup-WeeklyBackups" user="root" job="/usr/local/bin/mysqlbackup.WeeklyBackups.sh" tags: - mysql - cronjobs 

The shell script specified in the "task" was created a little earlier in the main.yml file.

This task will create a file in the /etc/cron.d/mysqlbackup-WeeklyBackups file:

 #Ansible: Backup mysql tables (weekly schedule) 20 5 * * sun root /usr/local/bin/mysqlbackup.WeeklyBackups.sh 
+16
source share

If you configure it to run on the crontab user:

 - name: Install Batchjobs on crontab cron: name: "Manage Disk Space" minute: "30" hour: "02" weekday: "0-6" job: "home/export/manageDiskSpace.sh > home/export/manageDiskSpace.sh.log 2>&1" #user: "admin" disabled: "no" become_user: "{{ admin_user }}" tags: - cronjobs 

Link [1]: https://docs.ansible.com/ansible/latest/cron_module.html

+1
source share

All Articles