Forum Discussion
Ansible - User Input
If a user is prompted for some input and in this case they don't input anything and just press enter a " '' " value is passed into the variable:
Example of the question:
- name: "vs_rule"
prompt: "enter the associated rule [Press enter to skip or enter in the following format: rule1 rule2]"
private: no
I'd like to use something similar to the below code but I don't want to pass the quotes onto the LTM (''), since the user will see the following error upon running the debug to show them the output: (note: this error is coming from the LTM, not Ansible after ""tmsh -c ''"" is entered in bash):
"std exception: (basic_string::substr), exiting..."
Is there a way to filter out the '' after the else and just send nothing to the LTM?
- "{{ 'tmsh list ltm rule ' + vs_rule + '' if vs_rule else '' |default([]) }}"
Here are two other ways this has been tried with no success:
- "{{ ((vs_rule | trim()) == "") | ternary(' do nothing', 'tmsh list ltm rule ' + vs_rule) }}"
and by adding the default field to the vars_propmt:
- name: "vs_rule"
prompt: "enter the associated rule [Press enter to skip or enter in the following format: rule1 rule2]"
private: no
default: ""
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com