当我使用 ansible module expect 时,我得到了这个消息:需要 pexpect python 模块 [英] When I use ansible module expect, I got this msg: The pexpect python module is required

查看:38
本文介绍了当我使用 ansible module expect 时,我得到了这个消息:需要 pexpect python 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ansible 来部署我们的系统.我在 yml 文件中使用了 expect 模块并尝试使用 ansible-playbook 来运行它并出现此错误:

I am trying to use ansible to deploy our system. I used expect module in yml file and try using ansible-playbook to run it and got this error:

致命:[192.168.100.132]:失败!=> {改变":假,失败":true, "msg": "需要 pexpect python 模块"}

fatal: [192.168.100.132]: FAILED! => {"changed": false, "failed": true, "msg": "The pexpect python module is required"}

然后我从 pypi.python.org 下载了 pexpect-4.2.1 包并通过python setup.py install"安装它.但它不起作用,错误从未改变.我应该怎么做来处理这个错误?

Then I downloaded the pexpect-4.2.1 package from pypi.python.org and install it by "python setup.py install". But it doesn't work and error never changed. What should I do to deal with the error ?

来自 yml 文件的一些代码:

Some code from yml file:

- 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 并这样做:

I downloaded the pexpect-4.2.1.tar.gz from pypi.python.org and did like this:

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].我需要在每个节点机器上安装它吗?

I installed it [pexpect] on the Ansible host. Do I need to install it on each node machine?

是的,模块在目标机器上执行,并且必须在其上安装先决条件(如果存在).

Yes, modules are executed on target machines and prerequisites (if they exist) must be installed on them.

这篇关于当我使用 ansible module expect 时,我得到了这个消息:需要 pexpect python 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆