controller_execution_environments.yml
In these files we configure the execution_environments for automation controller.
we will probably do this on the global configuration (ALL).
variables
The api understands the following structure for defining execution images:
{
"name": "",
"description": "",
"organization": null,
"image": "",
"credential": null,
"pull": ""
}
Below some examples how to use this.
group_vars/all/controller_execution_environments.yml
Here we see an example of the configuration for a credential to access gitlab.
---
controller_execution_environments_all:
- name: Automation Hub Default execution environment
description:
image: rhaap25.homelab/ee-supported-rhel8:latest
pull:
- name: Automation Hub Minimal execution environment
description:
image: rhaap25.homelab/ee-minimal-rhel8:latest
pull:
...
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_execution_environments.yml
Here we have a test execution_environment configured.
---
controller_execution_environments_dev:
- name: Gitlab Execution Environment
description: This is a test of a custom EE
image: rhaap25.homelab/ee_cac_image:1.0
pull:
credential: automation_hub_image_pull_secret
...
Here the variable has the "_dev" extension, so the variable will not be overridden.
group_vars/prod/controller_execution_environments.yml
As we do not configure extra execution_environments in prod, this file is an empty set.
---
controller_execution_environments_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_execution_environments_all
- controller_execution_environments_
We will merge these 2 variables into 1: controller_execution_environments and feed this to the infra.aap_configuration.controller_execution_environments role.
In main.yml the merge of the variables is done by this piece of code:
- name: Set the controller vars
ansible.builtin.set_fact:
controller_execution_environments: >
{{ controller_execution_environments_all |
community.general.lists_mergeby(vars['controller_execution_environments_' + branch_name],
'name', recursive=true, list_merge='append') }}
This results in the controller_execution_environments variable the collection needs.