I am very new to ansible and I am trying to run a playbook to change root password of hosts so I am using the expect command of pexpect module. I successfully managed to install pexpect v4.7 with python 2.7 on the hosts and on the local server running the playbook. However when the playbook is being run, it fails with error: “The pexpect python module is required”
According to the requirements, pexpect and python are of the correct version
JavaScript
x
10
10
1
Files installed on hosts for pexpect and python:
2
/usr/lib/python2.7/site-packages/pexpect
3
/usr/lib/python2.7/site-packages/pexpect-4.7.0-py2.7.egg-info
4
/usr/pexpect-4.7.0
5
/usr/pexpect-4.7.0/doc/api/pexpect.rst
6
/usr/pexpect-4.7.0/pexpect.egg-info
7
/usr/pexpect-4.7.0/tests/pexpectTest.py
8
/usr/pexpect-4.7.0/pexpect
9
/usr/pexpect-4.7.0/build/lib/pexpect
10
The playbook is as follows:
JavaScript
1
11
11
1
---
2
- hosts: all
3
become: true
4
5
tasks:
6
- name: change password for root user
7
expect:
8
command: passwd root
9
responses:
10
(?i)password: "password"
11
Am I doing something wrong? Please help!
Advertisement
Answer
I managed to fix the issue by removing pexpect from all hosts then installing epel-release, pip and pexpect packages accordingly.