简体   繁体   English

Crontab - Ansible 剧本

[英]Crontab - Ansible-playbook

I want to backup some switch configuration with ansible and trigger the the script by ansible daily.我想用 ansible 备份一些交换机配置,并每天通过 ansible 触发脚本。

If I use the cli manually, no problem in the directory ansible-playbook test.yml如果我手动使用 cli,目录ansible-playbook test.yml没有问题

With crontab使用 crontab

*/1 * * * * root /usr/bin/ansible-playbook /home/toto/Ansible/test.yml

I have the following message.我有以下消息。 The backup directory is in /home/toto/Ansible/备份目录在 /home/toto/Ansible/

TASK [RENAME BACKUP] ***********************************************************
fatal: [192.168.109.10]: FAILED! => {"changed": false, "checksum": "b202fa1d99ce10d27b223290ac40bc70c54639b3", "msg": "Destination directory ./backup does not exist"}
fatal: [192.168.109.11]: FAILED! => {"changed": false, "checksum": "93771b9c4b2455fafc0e9abe2aa83e1edf97867f", "msg": "Destination directory ./backup does not exist"}
fatal: [192.168.109.12]: FAILED! => {"changed": false, "checksum": "d121ab08b4f431f9b738c13f319c7ebd80694f63", "msg": "Destination directory ./backup does not exist"}

Someone has an idea?有人有想法吗?

Thanks谢谢

I found the solution that works, just change the directory fist我找到了可行的解决方案,只需更改目录拳头

*/2 * * * * root cd /home/toto/Ansible && ansible-playbook test.yml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM