controller_templates.yml
In these files we configure the templates for automation controller.
The infra.aap_configuration collection expects the vaules in the variable: controller_templates.
As we intend to configure everything just once, we spit the set of vars into the environments and join the lists in the main.yml, before calling the collection.
If there are no templates defined, do not add this file.
If you do, ensure the file is present in all branches, with the correct content, described below.
group_vars/all/controller_templates.yml
Here we configure a job template in all environments, so we can run this in any environment.
---
controller_templates_all:
- name: ORG_NEW_job_template_1
description: Our first job template
organization: ORG_NEW
project: ORG_NEW_project_1
inventory: ORG_NEW_inventory
playbook: main.yml
job_type: run
fact_caching_enabled: false
credentials:
- ORG_NEW_ansible
ask_scm_branch_on_launch: false
ask_tags_on_launch: false
ask_verbosity_on_launch: false
ask_variables_on_launch: false
extra_vars:
execution_environment: Default Execution Environment
survey_enabled: true
survey_spec:
name: ''
description: ''
spec:
- question_name: Enter var_1
question_description: ''
required: true
type: multiplechoice
variable: var_1
min: 0
max: 20
default: ''
choices:
- dev
- test
- accp
- prod
new_question: false
...
But you can already see that the variable name used here has the "_all" extension, so the variable will not be overridden as this is not quite a inventory.
Why we do this, will become clear in a moment.
group_vars/dev/controller_templates.yml
We configure extra templates in development, this an empty set at this moment (and probably will stay empty as thisis the base configuration).
---
controller_templates_dev: []
...
Here the variable has the "_dev" extension, so the variable will not be overridden.
group_vars/prod/controller_templates.yml
As we do not configure extra templates in prod, this file is an empty set.
---
controller_templates_prod: []
# No extra config exists
...
Here the variable has the "_prod" extension, so the variable will not be overridden.
When we run a pipeline for a certain environment, the inventory structure will provide us with 2 variables:
- controller_templates_all
- controller_templates_
We will merge these 2 variables into 1: controller_templates and feed this to the infra.aap_configuration.controller_templates role.