【问题标题】:When I use ansible module expect, I got this msg: The pexpect python module is required当我使用 ansible 模块期望时,我得到了这个消息:需要 pexpect python 模块
【发布时间】:2017-05-08 10:51:18
【问题描述】:

我正在尝试使用 ansible 来部署我们的系统。我在 yml 文件中使用了 expect 模块并尝试使用ansible-playbook 运行它并得到了这个错误:

致命:[192.168.100.132]:失败! => {“改变”:假,“失败”: 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

【问题讨论】:

  • 你在哪里安装了 pexpect?
  • 我在问题中添加了答案。请帮助我!
  • 当我问在哪里时,我的意思是在哪台机器上。
  • 对不起。我将它安装在 ansible 主机上。我需要在每个节点机器上安装它吗?

标签: ansible pexpect


【解决方案1】:

我将它 [pexpect] 安装在 Ansible 主机上。我需要在每台节点机器上安装它吗?

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

【讨论】:

  • 非常感谢。当我在目标机器上安装 pexpect 和 ptyprocess 时,它确实有效!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-01
  • 2018-06-08
  • 1970-01-01
相关资源
最近更新 更多