# ansible2.0 expect module not working

**URL:** <https://forum.ansible.com/t/ansible2-0-expect-module-not-working/19909>\
**Category:** Ansible Project\
**Created:** [December 1, 2015, 4:12pm UTC](https://forum.ansible.com/t/ansible2-0-expect-module-not-working/19909 "2015-12-01T16:12:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@Karan\_Singh](https://forum.ansible.com/u/Karan_Singh)\
**Post date:** [December 1, 2015, 4:12pm UTC](https://forum.ansible.com/t/ansible2-0-expect-module-not-working/19909/1 "2015-12-01T16:12:25Z")

</div>

Hello Guys

Here is my ansible task

- name: Firmware path lookup  
shell: rpm -ql hp-firmware-“{{ device.stdout }}” | grep ‘.scexe’  
register: FirmwarePath

- expect:  
command: sh “{{ FirmwarePath.stdout }}”  
responses:  
“Continue (y/N)”: ‘y’

And it ends up like this.

TASK [ansible-role-hp-firmware-upgrade : expect command=sh “{{ FirmwarePath.stdout }}” responses={u’Continue (y/N)‘: u’y’}] \*\*\*  
fatal: [storage0204]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Traceback (most recent call last):\r\n File "/home/ksingh/.ansible/tmp/ansible-tmp-1448985850.39-65513584639595/expect", line 2084, in \r\n main()\r\n File "/home/ksingh/.ansible/tmp/ansible-tmp-1448985850.39-65513584639595/expect", line 154, in main\r\n out, rc = pexpect.runu(args, timeout=timeout, withexitstatus=True,\r\nAttributeError: ‘module’ object has no attribute ‘runu’\r\n”, “parsed”: false}

If i run this manually with script command it works nicely.  
Can you please advice , how can i make this work.

- Karan -

---

<div class="post-metadata">

**Author:** ![Michele\_Kappa](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Michele\_Kappa](https://forum.ansible.com/u/Michele_Kappa)\
**Post date:** [December 3, 2015, 2:52pm UTC](https://forum.ansible.com/t/ansible2-0-expect-module-not-working/19909/2 "2015-12-03T14:52:14Z")

</div>

Exactly the same is happening over here, trying to use expect, having installed the pexpect package earlier in the role tasks. Here is the -vvvv of ansible, trying to install a gitlab ci runner:

fatal: [xxx.yyy.zzz]: FAILED! =\> {“changed”: false, “failed”: true, “invocation”: {“module\_args”: {“command”: “gitlab-ci-multi-runner register”, “responses”: {“Please enter the gitlab-ci coordinator URL (e.g. [https://gitlab.com/ci](https://gitlab.com/ci) )”: “[https://gitlab.com/ci](https://gitlab.com/ci)”, “Please\ enter\ the\ Docker\ image\ \(eg\. ruby\:2\.1\)\:”: “ruby:2.1”, “Please\ enter\ the\ executor\:\ shell\,\ docker\,\ docker\-ssh\,\ ssh\?”: “docker”, “Please\ enter\ the\ gitlab\-ci\ description\ for\ this\ runner”: “my-runner”, “Please\ enter\ the\ gitlab\-ci\ token\ for\ this\ runner”: “xxxxxxxxxxxxxxxxxxxxxx”}}, “module\_name”: “expect”}, “msg”: “Traceback (most recent call last):\r\n File "/home/mkappa/.ansible/tmp/ansible-tmp-1449154083.59-269753732902654/expect", line 2084, in \r\n main()\r\n File "/home/mkappa/.ansible/tmp/ansible-tmp-1449154083.59-269753732902654/expect", line 154, in main\r\n out, rc = pexpect.runu(args, timeout=timeout, withexitstatus=True,\r\nAttributeError: ‘module’ object has no attribute ‘runu’\r\nOpenSSH\_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh\_config\r\ndebug1: /etc/ssh/ssh\_config line 56: Applying options for \*\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O\_NONBLOCK\r\ndebug2: mux\_client\_hello\_exchange: master version 4\r\ndebug3: mux\_client\_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux\_client\_request\_session: entering\r\ndebug3: mux\_client\_request\_alive: entering\r\ndebug3: mux\_client\_request\_alive: done pid = 3439\r\ndebug3: mux\_client\_request\_session: session request sent\r\ndebug1: mux\_client\_request\_session: master session id: 2\r\ndebug3: mux\_client\_read\_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to [cremaster2.aavv.io](http://cremaster2.aavv.io) closed.\r\n”, “parsed”: false}

Any ideas?

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [December 3, 2015, 4:19pm UTC](https://forum.ansible.com/t/ansible2-0-expect-module-not-working/19909/3 "2015-12-03T16:19:35Z")

</div>

What version of pexpect are the two of you using?

---

<div class="post-metadata">

**Author:** ![Karan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@Karan\_Singh](https://forum.ansible.com/u/Karan_Singh)\
**Post date:** [December 3, 2015, 4:41pm UTC](https://forum.ansible.com/t/ansible2-0-expect-module-not-working/19909/4 "2015-12-03T16:41:03Z")

</div>

i have updated pexpect version to 4.0.1 and it worked.
