ansible2.0 expect module not working

497 views
Skip to first unread message

Karan Singh

unread,
Dec 1, 2015, 11:12:25 AM12/1/15
to Ansible Project
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 <module>\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 -




Michele Kappa

unread,
Dec 3, 2015, 10:00:20 AM12/3/15
to Ansible Project
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", "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 <module>\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 closed.\r\n", "parsed": false}

Any ideas?

Toshio Kuratomi

unread,
Dec 3, 2015, 11:19:47 AM12/3/15
to ansible...@googlegroups.com
What version of pexpect are the two of you using?
> --
> 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/0fc45997-057b-4286-9d89-e65fdb133ec1%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Karan Singh

unread,
Dec 3, 2015, 11:41:10 AM12/3/15
to ansible...@googlegroups.com
i have updated pexpect version to 4.0.1 and it worked.

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/ctcjL3KXYZI/unsubscribe.
To unsubscribe from this group and all its topics, 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