`vars` operates inconsistently in different combinations of Ansible (full/base/core) and Python versions. Variables are now instead explicitly loaded under a subkey, which also removes the need for filtering and makes access more explicit and semantic.
49 lines
1.4 KiB
YAML
49 lines
1.4 KiB
YAML
---
|
|
- name: explicitly load vars under a subkey for reliable access
|
|
include_tasks: load_vars.yml
|
|
|
|
- name: set facts from role vars
|
|
set_fact:
|
|
demo_list: "{{ ( job_template_definitions|map(attribute='key')|list }}"
|
|
full_demo_info: "{{ job_template_definitions|dict2items) }}"
|
|
|
|
- name: provide info to terminal window
|
|
debug:
|
|
msg:
|
|
- "install {{ demo }} on {{ my_tower_host }}"
|
|
- "total demos: {{ demo_list | length }}"
|
|
- "available demos are: {{ demo_list }}"
|
|
|
|
- name: make sure demo is a valid demo
|
|
assert:
|
|
that:
|
|
- demo is defined
|
|
- demo in demo_list or demo == "all"
|
|
msg:
|
|
- "demo must be defined and be one of: {{ demo_list }}"
|
|
- "full list can be found on https://github.com/ansible/product-demos"
|
|
|
|
- name: setup public cloud credentials
|
|
include_tasks: "{{item}}"
|
|
with_first_found:
|
|
- "{{role_path}}/tasks/{{public_cloud}}.yml"
|
|
- "{{role_path}}/tasks/unsupported_cloud.yml"
|
|
|
|
- name: install all job templates
|
|
include_tasks: job_template_loop.yml
|
|
loop: "{{ full_demo_info }}"
|
|
when: demo == "all"
|
|
|
|
- name: install single job template
|
|
include_tasks: job_template.yml
|
|
when:
|
|
- demo != "all"
|
|
- job_template_definitions[demo].workflow is not defined or not job_template_definitions[demo].workflow
|
|
|
|
- name: install single workflow
|
|
include_tasks: workflow.yml
|
|
when:
|
|
- demo != "all"
|
|
- job_template_definitions[demo].workflow is defined
|
|
- job_template_definitions[demo].workflow
|