我尝试在 Redhat7 中使用 pexpect for ansible,但无法安装它。我只得到 pexpect.noarch 2.3-11.el7 @RHEL7 版本。或者 pexpect 是否有替代方法来执行命令并响应提示?
看起来pexpect
RHEL7 附带的 Python 模块版本对于 Ansible 来说太旧了(RHEL7 有 pexpect 2.3,而 Ansible 需要 3.3 或更高版本)。您最好的选择可能是使用shell
orcommand
模块来运行expect
;该shell
模块的文档中有一个这样的示例:
# You can use shell to run other executables to perform actions inline
- name: Run expect to wait for a successful PXE boot via out-of-band CIMC
shell: |
set timeout 300
spawn ssh admin@{{ cimc_host }}
expect "password:"
send "{{ cimc_password }}\n"
expect "\n{{ cimc_name }}"
send "connect host\n"
expect "pxeboot.n12"
send "\n"
exit 0
args:
executable: /usr/bin/expect
delegate_to: localhost
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2835 次 |
最近记录: |