我的在工做中使用ansible的过程当中发现一个问题,我记录下来备忘。
若是你须要在使用 sudo 时指定密码,可在运行 ansible-playbook 命令时加上选项--ask-sudo-pass
shell
ansible-playbook -i hosts playbook.xml --ask-sudo-pass
若是使用sudo
时,playbook
疑似被挂起,多是在sudo prompt
处被卡住,这时可执行Control-C
杀死卡住的任务,再从新运行一次.bash
使用 command module
和 shell module
时,咱们须要关心返回码信息,若是有一条命令,它的成功执行的返回码不是0, 你或许但愿这样作:this
tasks: - name: run this command and ignore the result shell: /usr/bin/somecommand ignore_errors: True