Trouble with expect: passing creds

1,309 views
Skip to first unread message

Jeff Rogers

unread,
May 26, 2016, 12:24:12 PM5/26/16
to Ansible Project
I'm getting the following error:

...... "msg": "argument responses is of type <type 'list'> and we were unable to convert to dict"

I'm trying to do this.

- name: Name of the thing I'm doing
hosts: '{{ target }}'
serial: 1
vars_prompt:
- name: "UserName"
prompt: "User Name "
private: yes

- name: "UserPWD"
prompt: "Password "
private: yes

- expect:
echo: yes
command: /use/bin/mybinary argument
responses:
- 'Username': "{{ UserName }}"
- 'Password': "{{ UserPWD }}"

Matt Martz

unread,
May 26, 2016, 12:29:01 PM5/26/16
to ansible...@googlegroups.com
Your `responses` argument needs to be a hash/dict, not an array/list:

- expect:
    echo: yes
    command: /use/bin/mybinary argument
    responses:
      'Username': "{{ UserName }}"
      'Password': "{{ UserPWD }}"

The only change above is removing the `- ` from before each question/answer.


--
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/8b2d6609-1a9d-45ec-ab2e-ffbcb36cb8f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Jeff Rogers

unread,
Jun 3, 2016, 5:19:49 PM6/3/16
to Ansible Project
Excellent, that fixed it, thank you. I can't seem to get a become: / become_user: to work in the -expect task now. Had to pass it in as a global.
Reply all
Reply to author
Forward
0 new messages