hub_collections
It is possible to add custom collections here to load into the automation hub, or in a disconnected environment load any collection.
You will need to povide the tar.gz file for the collection to load iot this way.
For custom collections we like to do this another way, wich will be discusssed later (you can find it in the configuration as code description for automation platform 2.4).
group_vars/all/hub_collections.yml
As we do not configure custom collections in automation hub, this file is an empty set. We add custom collections after the base configuration as they will be updated regularly, these will become outdated.
---
hub_collections_all: []
# No extra config exists
...
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/hub_collections.yml
As we do not configure collections inautomation hub, this file is an empty set.
---
hub_collections_dev: []
# No extra config exists
...
Here the variable has the "_dev" extension, so the variable will not be overridden.
group_vars/prod/hub_collections.yml
As we do not configure collections in automation hub, this file is an empty set.
---
hub_collections_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:
- hub_collections_all
- hub_collections_
We will merge these 2 variables into 1: hub_collections and feed this to the infra.aap_configuration.hub_collections role.
In main.yml the merge of the variables is done by this piece of code:
- name: Set the gateway vars
ansible.builtin.set_fact:
hub_collections: >
{{ hub_collections_all |
community.general.lists_mergeby(vars['hub_collections_' + branch_name],
'name', recursive=true, list_merge='append') }}
This results in the hub_collections variable the collection needs.