我需要在期望脚本中使用我的 --ask-become-pass 密码。有没有办法使用在变量中启动 ansible_playbook 时输入的密码?
伪代码:
# ansible-playbook --become --ask-become-pass -i testing master.yml
BECOME password: secretpassword
Run Code Online (Sandbox Code Playgroud)
然后在任务中
- name: use pw variable in task
expect:
command: /bin/bash -c "/usr/bin/my_command"
responses:
Password: "{{ prompted_pass }}"
Run Code Online (Sandbox Code Playgroud)
在阅读“密码”提示时,我希望输入“secretpassword”
我知道“become_user”,不幸的是它对我的情况没有帮助,因为远程服务器要求输入密码 - 但它与“become_password”相同。
我尝试转储变量和环境,但找不到任何有用的东西。
谢谢,托比亚斯
不可以。剧本无法使用交互式密码。
一种替代方法是不使用密码--ask-become-pass
,而是将密码作为变量提供。将变量定义ansible_become_password
为查找表达式,它从您使用的任何秘密存储中获取密码。也可以使用此变量作为其他程序的密码。
归档时间: |
|
查看次数: |
6913 次 |
最近记录: |