Ansible not recognizing correct pexpect module?

`

$ ansible --version
ansible 2.4.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/home/scscm_builder/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible-2.4.0.0-py2.7.egg/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.14 (default, Nov 10 2017, 18:14:45) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

`

I’m trying to make the “expect” module in ansible, and I get

`

fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Insufficient version of pexpect installed (2.3), this module requires pexpect>=3.3. Error was ‘module’ object has no attribute ‘runu’”}

`

But pip tells me I already pexpect version 4.5.0?

`

$ pip2.7 install --upgrade pexpect
Requirement already up-to-date: pexpect in /usr/local/lib/python2.7/site-packages (4.5.0)
Requirement not upgraded as not directly required: ptyprocess>=0.5 in /usr/local/lib/python2.7/site-packages (from pexpect) (0.5.2)

`

What am I missing?

I meant to say “I’m trying to use the “expect” module in ansible…”

It requires it on the machine and python the module executes on, use
-vvv to verify you are matching both, by default the implicit
localhost should ensure that they are the same as you expect, but if
you added localhost to your inventory you might be using a different
python http://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html

Thanks Brian. I should’ve indicated that I’m running this on localhost

$ ansible-playbook -i "localhost," test-expect.yml

I added the

`
ansible_python_interpreter: python2.7

`

in my playbook and it worked for now. For some reason, this “{{ ansible_playbook_python }}” didn’t work for me, but I’ll debug that next.

The -i 'localhost,' is probably what is causing the issue as you are
defining localhost, see the docs i linked in previous message for a
full explanation.