当我使用ansible模块expect时,我得到了以下消息:pexpect python模块是必需的

当我使用ansible模块expect时,我得到了以下消息:pexpect python模块是必需的,ansible,pexpect,Ansible,Pexpect,我正在尝试使用ansible部署我们的系统。我在yml文件中使用了expect模块,并尝试使用ansible playbook运行该模块,但出现以下错误: 致命:[192.168.100.132]:失败!=>{“更改”:false,“失败”: true,“msg”:“需要pexpect python模块”} 然后我从pypi.python.org下载了pexpect-4.2.1包,并通过“python setup.py install”安装它。 但它不起作用,错误从未改变。 我应该如何处理错误

我正在尝试使用ansible部署我们的系统。我在yml文件中使用了expect模块,并尝试使用
ansible playbook
运行该模块,但出现以下错误:

致命:[192.168.100.132]:失败!=>{“更改”:false,“失败”: true,“msg”:“需要pexpect python模块”}

然后我从pypi.python.org下载了pexpect-4.2.1包,并通过“python setup.py install”安装它。 但它不起作用,错误从未改变。 我应该如何处理错误

yml文件中的一些代码:

- name: auth root
  expect:
    command: mysql_secure_installation
    responses:
      'Enter password for user root:': '{{password.stdout}}'
      'New password:': 'dtise123'
      'Re-enter new password:': 'dtise123'
      'Do you wish to continue with the password provided\?\(Press y\|Y for Yes, any other key for No\) :': 'y'
      'Remove anonymous users\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
      'Disallow root login remotely\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
      'Remove test database and access to it\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
      'Reload privilege tables now\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
    echo: yes
我从pypi.python.org下载了pexpect-4.2.1.tar.gz,如下所示:

mv pexpect-4.2.1.tar.gz /usr/local/src/
cd /usr/local/src
tar zxvf pexpect-4.2.1.tar.gz
cd pexpect-4.2.1
python setup.py install
我在Ansible主机上安装了它[pexpect]。我需要在每个节点计算机上安装它吗


是的,模块是在目标机器上执行的,必须在目标机器上安装前提条件(如果存在)。

您在哪里安装了pexpect?我在问题中添加了答案。请帮助我!当我问到哪里时,我的意思是在哪台机器上。对不起。我在ansible主机上安装了它。我需要在每个节点机器上安装它吗?非常感谢。当我在目标机器上安装了pexpect和ptyprocess时,它确实可以工作!