fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "sudo:抱歉,您必须拥有一个终端来执行 sudo ", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1} [WARNING]: Could not create retry file '/tmp/ansible-playbook- sample/site.retry'. [Errno 13] Permission denied: u'/tmp/ansible- playbook-sample/site.retry'
解决方法:
1. centos环境下,在/etc/sudoers.d/ 目录下,增加一个 jenkins文件,内容如下:
Defaults:jenkins !requiretty jenkins ALL=(ALL) NOPASSWD: ALL
2. 在脚本中命令前,增加sudo命令即可,或sudo 执行脚本
sudo /opt/webmaster/sitedeploy.sh --source $BUILD_DIR --site xxx.com --clear