When I use ansible module expect, I got this msg: The pexpect python module is required

ε祈祈猫儿з 提交于 2021-01-28 05:41:16

问题


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:

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

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 ?

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

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

回答1:


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.



来源:https://stackoverflow.com/questions/43845748/when-i-use-ansible-module-expect-i-got-this-msg-the-pexpect-python-module-is-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!