controller_templates.yml
In these files we configure the templates for automation controller.
variables
The structure to define jobb_templates in controller, as exposed by the api.
{
"name": "",
"description": "",
"job_type": "run",
"inventory": null,
"project": null,
"playbook": "",
"scm_branch": "",
"forks": 0,
"limit": "",
"verbosity": 0,
"extra_vars": "",
"job_tags": "",
"force_handlers": false,
"skip_tags": "",
"start_at_task": "",
"timeout": 0,
"use_fact_cache": false,
"execution_environment": null,
"host_config_key": "",
"ask_scm_branch_on_launch": false,
"ask_diff_mode_on_launch": false,
"ask_variables_on_launch": false,
"ask_limit_on_launch": false,
"ask_tags_on_launch": false,
"ask_skip_tags_on_launch": false,
"ask_job_type_on_launch": false,
"ask_verbosity_on_launch": false,
"ask_inventory_on_launch": false,
"ask_credential_on_launch": false,
"ask_execution_environment_on_launch": false,
"ask_labels_on_launch": false,
"ask_forks_on_launch": false,
"ask_job_slice_count_on_launch": false,
"ask_timeout_on_launch": false,
"ask_instance_groups_on_launch": false,
"survey_enabled": false,
"become_enabled": false,
"diff_mode": false,
"allow_simultaneous": false,
"job_slice_count": 1,
"webhook_service": null,
"webhook_credential": null,
"prevent_instance_group_fallback": false
}
group_vars/all/controller_templates.yml
Here we configure the recovery templates in all environments, so we can recover any environment, from any environment.
---
controller_templates_all:
- name: MGT_Recover_All_Organizations
description: Restart all CaC pipelines for teams
organization: MGT
project: MGT_recover_aap_organizations
inventory: MGT_inventory
playbook: main.yml
job_type: run
fact_caching_enabled: false
credentials:
- MGT_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: Gitlab Execution Environment
survey_enabled: true
survey_spec:
name: ''
description: ''
spec:
- question_name: Env to recover
question_description: ''
required: true
type: multiplechoice
variable: gitlab_env_branch
min: 0
max: 20
default: ''
choices:
- dev
- test
- accp
- prod
new_question: false
- name: MGT_Configure Automation Hub
description: Restart all Config pipelines for automation hub
organization: MGT
project: MGT_config_ahub
inventory: MGT_inventory
playbook: main.yml
job_type: run
fact_caching_enabled: false
credentials:
- MGT_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: Gitlab Execution Environment
survey_enabled: false
survey_spec:
name: ''
description: ''
spec:
- question_name: Env to configure
question_description: ''
required: true
type: multiplechoice
variable: gitlab_env_branch
min: 0
max: 20
default: 'dev'
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.