I am trying to get information from tower surveys and running in a road block. I have the following code.
- name: Gather all Job Templates
shell: awx job_templates list -f human --filter 'Id' --all --survey_enabled true | tail -n +3
register: job_templates_all
when: update_all is 'True'
- name: Gather survey of templates
uri:
url: "https://{{ tower_env }}.fqdn.com/api/v2/job_templates/{{ item }}/survey_spec/"
method: GET
return_content: yes
user: "{{ tower_username }}"
password: "{{ tower_password }}"
force_basic_auth: yes
body_format: json
validate_certs: no
register: survey
when: update_all is 'True'
with_items: "{{ job_templates_all.stdout }}"
I need to get a list of all job templates that has a specific key:value pair in the survey and and then loop through that list and provide my a new job template list based on ID.
Here is an example of the registered survey var
"json": {
"description": "",
"name": "",
"spec": [
{
"question_description": "",
"min": null,
"default": "",
"max": null,
"required": true,
"choices": "foo\bar",
"variable": "account",
"question_name": "Account",
"type": "multiplechoice"
},
{
"question_description": "",
"min": null,
"default": "us-east-1",
"max": null,
"required": true,
"choices": "us-east-1\nus-west-2",
"new_question": true,
"variable": "region",
"question_name": "Region",
"type": "multiplechoice"
},
If it finds "variable": "account", I need to get of all job templates that have this.