I have been trying to configure a cron job to run my ansible playbook every hour. I could not find any relevant examples on how to start the configuration . I have tried the below task in a separate ansible playbook and it shows the below output for crontab -l, but not execution seems to be happening. Help will be high appreciated.
root@ubuntu:/etc/ansible/# crontab -l
57 10 * * * ansible-playbook crontest.yaml
- name: Run an ansible playbook"
cron:
name: "Run play"
minute: "57"
hour: "10"
job: "ansible-playbook crontest.yaml"
Cron Logs:
Nov 24 07:35:01 ABC30VDEF290021 CRON[13951]: (root) CMD (echo "testing" > /etc/ansible/automation/logs/test.txt)
Nov 24 07:35:01 ABC30VDEF290021 CRON[13948]: (root) CMD ( /usr/bin/ansible-playbook /etc/ansible/automation/crontest.yml)
Nov 24 07:35:01 ABC30VDEF290021 CRON[13949]: (root) CMD (/usr/local/bin/ansible-playbook /etc/ansible/automation/main.yaml)
Crontab -e
#Ansible: Run play
*/1 * * * * /bin/sh -c '. ~/.profile; /usr/local/bin/ansible-playbook /etc/ansible/automation/crontest.yml
*/1 * * * * echo "testing" > /etc/ansible/automation/logs/test.txt
35 7 * * * /usr/local/bin/ansible-playbook /etc/ansible/automation/main.yaml