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

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论