Unable to run 'expect' module

28 views
Skip to first unread message

Alain Désilets

unread,
Feb 6, 2019, 7:51:39 AM2/6/19
to Ansible Project
I am trying to run a playbook (see end of the post), which invokes the 'expect' module.

But when I run it, I get error:

TASK [Run anaconda installation script] ****************************************


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


Yet, the 'pip' task that is supposed to install pexpect runs without error.

What am I doing wrong?

Thx.

Alain Désilets

Content of the playbook:

---
- name: Run Anaconda shell

hosts: all
vars:
conda_home: "~/anaconda2-NEW"
conda_inst_sh_path: /path/to/Anaconda2-2018.12-MacOSX-x86_64.sh

tasks:

- name: install pexpect
pip:
name: pexpect
become: yes
become_user: root

- name: Run anaconda installation script
expect:
command: "sh {{conda_inst_sh_path}}"
responses:
(?i)password: "MySekretPa$$word"
become: yes
become_user: root





Diptajeet Khan

unread,
Feb 6, 2019, 8:22:54 AM2/6/19
to ansible...@googlegroups.com
Install "expect" using "yum" rather than "pexpect" using "pip".

Best Regards
Diptajeet

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c849621b-4643-477b-a8b8-59d8e29a31e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alain Désilets

unread,
Feb 6, 2019, 9:23:48 AM2/6/19
to ansible...@googlegroups.com
On Wed, Feb 6, 2019 at 8:22 AM Diptajeet Khan <dipt...@gmail.com> wrote:
Install "expect" using "yum" rather than "pexpect" using "pip".

Thx Diptajeet,

I am on OSX, so I can't install with yum. I did however install 'expect' using homebrew as follows:

   brew install expect

This installed v5.45.4 of expect. Yet, I still get the pexpect error message.

Alain

Diptajeet Khan

unread,
Feb 6, 2019, 9:30:03 AM2/6/19
to ansible...@googlegroups.com
I see. Can you also try "brew install pexpect" and run the Ansible code.

Best Regards
Diptajeet

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Alain Désilets

unread,
Feb 6, 2019, 10:23:58 AM2/6/19
to ansible...@googlegroups.com
On Wed, Feb 6, 2019 at 9:29 AM Diptajeet Khan <dipt...@gmail.com> wrote:
I see. Can you also try "brew install pexpect" and run the Ansible code.

Found it! By default, Ansible uses a particular path for finding the Python interpreter it uses to run the playbooks. This turned out to be different from the interpreter on which I had isntalled pexpect.

I fixed the issue by passing the following argument to my ansible-playbook command:

       -e 'ansible_python_interpreter=/path/to/my/python

Alain

Diptajeet Khan

unread,
Feb 6, 2019, 10:59:02 AM2/6/19
to ansible...@googlegroups.com
Alright!

Best Regards
Diptajeet

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages