Ansible not recognizing correct pexpect module?

2,739 views
Skip to first unread message

ZillaYT

unread,
May 14, 2018, 11:35:43 AM5/14/18
to Ansible Project
$ 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?

ZillaYT

unread,
May 14, 2018, 12:02:01 PM5/14/18
to Ansible Project
I meant to say "I'm trying to use the "expect" module in ansible..."

Brian Coca

unread,
May 14, 2018, 12:11:43 PM5/14/18
to Ansible Project
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

----------
Brian Coca

ZillaYT

unread,
May 14, 2018, 12:33:19 PM5/14/18
to Ansible Project
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.

Brian Coca

unread,
May 14, 2018, 12:42:40 PM5/14/18
to Ansible Project
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.




--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages