在RedHat7上使用pexpect还是适用的还是执行命令并响应提示的替代方法? [英] Is it still applicable to use pexpect on RedHat7 or is there alternative way to Executes a command and responds to prompts?
问题描述
我试图在Redhat7中使用pexpect进行ansible,但无法安装它.我只得到pexpect.noarch 2.3-11.el7 @ RHEL7版本.还是pexpect可以执行命令并响应提示?
I'm trying to use pexpect in Redhat7 for ansible but I wasn't able to install it. I was only getting pexpect.noarch 2.3-11.el7 @RHEL7 version. Or is there a alternative for pexpect to Executes a command and responds to prompts?
推荐答案
RHEL7随附的 pexpect
Python模块的版本对于Ansible而言太旧了(RHEL7具有pexpect 2.3和Ansible要求3.3或更高).最好的选择可能是使用 shell
或 command
模块来运行 expect
; shell
模块:
It looks like the version of the pexpect
Python module shipped with RHEL7 is too old for Ansible (RHEL7 has pexpect 2.3, and Ansible wants 3.3 or greater). Your best option is probably to use the shell
or command
module to run expect
; there is an example of this in the documentation for the shell
module:
# 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
这篇关于在RedHat7上使用pexpect还是适用的还是执行命令并响应提示的替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!