I have a weird behavior on a crontab job I'm trying to run using Ansible's playbook.
First of all, I have similar crontab's lines using Ansible playbooks that works perfectly, so the issue is either this particular playbook or something is missing in the crontab options maybe.
Anyway, the playbook does the following:
1.- Ubuntu server (Local-host), which is the one running the playbook, compress "Documents" folder into a .zip file and stores it in /home/user.
2.- A ssh connection to NAS server (Remote-host) to Copy .zipped "Documents" folder to NAS and then I change the name of the .zip file using a local naming convention.
3.- Clean up .zip files in Ubuntu.
So, like I say in the title, when I run the playbook from terminal using:
$ sudo ansible-playbook ubuntu2nasBackup.yml
The playbook works perfectly: zip file creation -> copied via ssh to remote host -> clean up .zip file.
When I try to add to crontab job (root crontab I must add), the bullet #1 above is created, but then the zip file is not copied to remote host.
$ sudo crontab -e
22 20 * * * /usr/bin/ansible-playbook /home/user/Documents/ansible101/ubuntu2nasBackup.yml
I have tried to search (unsuccessfully) a way to t-shoot and have some feedback on the error or time-out that must be happening, but nothing seems to work.
Is there anything I'm missing? Is there any tip I can follow?
If the playbook is necessary to reveal, let me know, but like I said if I run thos from terminal, it works.