Trouble with expect: passing creds

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 }}"

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.

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.