ansible略过sudo时交互输入密码

我的在工做中使用ansible的过程当中发现一个问题,我记录下来备忘。
若是你须要在使用 sudo 时指定密码,可在运行 ansible-playbook 命令时加上选项--ask-sudo-passshell

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
相关文章
相关标签/搜索