Async and expect module

177 views
Skip to first unread message

David González Martínez

unread,
Apr 12, 2016, 10:09:15 AM4/12/16
to Ansible Project
I'm trying to use expect Ansible module to perform an interactive task in a virtual machine. The module works, but the task is very long and I have problems with the timeout. I get an error like this. I tried to use async but it fails and returns this error:

[0;32m    qemu: fatal: [deploy]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"async": 600, "command": "config_exec", "poll": 300, "responses": {"(?i)continue": "y", "(?i)password": "pass"}}, "module_name": "expect"}, "msg": "unsupported parameter for module: async"}

This is the part of my playbook with problems:

# Configure system for user
- hosts: deploy
  tasks:
  - shell: whoami
    register: result
  - debug: var=result
  - name: configuration
    expect:
     command: config_exec
     responses:
      (?i)password: "{{pass}}"
      (?i)continue: "y"
     async: 600
     poll: 300

Is there any way to make expect and async to work together?
 

Matt Davis

unread,
Apr 12, 2016, 2:58:17 PM4/12/16
to Ansible Project
You need to outdent async/poll args- those are task args, not module args (so they need to line up with name and "expect").

David González Martínez

unread,
Apr 14, 2016, 4:34:34 AM4/14/16
to Ansible Project
I outdented async and poll and now it complains about syntax. In Ansible documentation is aligned with the command, not the task.

David González Martínez

unread,
Apr 22, 2016, 8:34:38 AM4/22/16
to Ansible Project
Finally I was able to make it work without async. Using the parameter timeout in expect module. It seems that expect keeps waiting for the input even if there is no need and I had to add the timeout to let the command run without problems.
Reply all
Reply to author
Forward
0 new messages