0

I want to pass the values to roles from the input which im getting from vars_prompt. Kindly advise is it possible or not.

-name: Topic creation
 hosts: all
 vars_prompt:
  - name: environment
    prompt: "Enter the environment"
    private: no
 roles:
  - "{{ environmet }}"

When i run the playbook getting an error. Error! environment is undefined

Kindly advise how to pass the value to roles.

Want to pass the values to roles.

1 Answers1

0

If I understand that corerct the error you are observing is usually because of the variable initialization difference between compile time and runtime.

According the error message

 roles:
  - "{{ environment }}"

would be resolved during compile time and before the prompting for the environment during runtime.

 vars_prompt:
  - name: environment
    prompt: "Enter the environment"
    private: no

You may also have a look into further documentation about

This means you would need to change the way you are referencing the role or providing the name for it. See a

Similar Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40