ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
948 stars 1.46k forks source link

can not use variable in responses key of expect module #3640

Closed hanks closed 7 years ago

hanks commented 7 years ago
ISSUE TYPE
COMPONENT NAME

expect

ANSIBLE VERSION
ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides
OS / ENVIRONMENT

macOS 10.11.3

SUMMARY

can not use variable in responses key of expect module

- name: expect test
   expect: 
     command: xxxx
     response:
       "{{ path }}": "yes"
EXPECTED RESULTS

It should check the prompt with the path value, and input yes

ACTUAL RESULTS

No response for the prompt

ansibot commented 7 years ago

@sivel ping, this issue is waiting for your response. click here for bot help

sivel commented 7 years ago

This is not specific to the expect module. Using variables as keys is unsupported throughout ansible.

Maybe you could instead define a variable like:

vars:
    path_responses:
        "/foo/bar/baz": "yes"

And then supply that to responses like:

responses: "{{ path_responses }}"

If you have further questions please stop by IRC or the mailing list: