ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.97k stars 3.41k forks source link

RFE: Need for survey type supporting YAML #6105

Open r1k0 opened 4 years ago

r1k0 commented 4 years ago
ISSUE TYPE
SUMMARY

We are an international company using Tower for network automation (RH contract). We are in the process of pushing all our plays to templates in tower, we want to extensively use the survey feature to let users input data for specific variables. So far so good.

More precisely, we want to use survey to have list of dictionnaries as input variable for specific playbooks. However, the only type of survey that can allow that, the textarea, is not processed as YAML. This forces our developers to pretask all those manual playbooks with:

set_fact:  user_input_var="{{ user_input_var | from_yaml }}"

The reason to do so, if I understand correctly, is because the variable is set as:

user_input_var: |-

The hyphen here creates the trouble, as we only need:

user_input_var: |

If I use the GUI extra var in the template and set it as "user_input_var: |" the data is processed as YAML and all is fine, a data structure such as the one below works:

user_input_var: |
  - { key1: val1,
      key2: val2
    }
  - { key1: val3,
      key2: val4
    }

=> we would like to suggest the addition of another type of survey: textarea (YAML)

Where we can input a multiple line YAML variables (a list of dict) the same we do via group_vars or host_vars. Basically, it is the same as the existing textarea except that it's processed by "| from_yaml" so that we can keep the consistency between how ansible works in CLI and via tower (if somehow tower is not reachable when we need it - disaster recovery or else - we want to make sure CLI and GUI works with the same data structure).

r1k0 commented 4 years ago

meanwhile, we found a workaround.

We use the extravar box prompt in the template. We set it as:

---
# DOCUMENTATION: https://<link to doc for that variable>
BIGIP_VIP_input:
# Paste the data structure hereunder

When run, user gets prompted and can paste the data structure.

Still, it'd be good if one could use a list of dict as input for textarea survey without parsing it to yaml on the playbook side.

kladiv commented 2 years ago

+1 (for YAML and JSON format)