controller_schedules.yml

In these files we configure the schedules for automation controller.
we will probably do this on each environment separately, as the hostnames differ.

The infra.aap_configuration collection expects the vaules in the variable: controller_schedules. 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 schedules defined, do not add this file. If you do, ensure the file is present in all branches, with the correct content, described below.

variables

The api understands the following structure to define schedules in rhaap:

{
    "rrule": "",
    "name": "",
    "description": "",
    "extra_data": {},
    "inventory": null,
    "scm_branch": "",
    "job_type": null,
    "job_tags": "",
    "skip_tags": "",
    "limit": "",
    "diff_mode": null,
    "verbosity": null,
    "execution_environment": null,
    "forks": null,
    "job_slice_count": null,
    "timeout": null,
    "unified_job_template": null,
    "enabled": true
}

group_vars/all/controller_schedules.yml

Here we see an empty set for all.

---
controller_schedules_all: []
...

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_schedules.yml

As we do not configure extra schedules in development, this file is an empty set.
(We use the containerized setup version, so no need for schedules).

---
controller_schedules_dev: []
  # No extra config exists
...

Here the variable has the "_dev" extension, so the variable will not be overridden.

group_vars/prod/controller_schedules.yml

As we do not configure extra schedules in prod, this file is an empty set.

---
controller_schedules_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_schedules_all
- controller_schedules_

We will merge these 2 variables into 1: controller_schedules and feed this to the infra.aap_configuration.controller_schedules 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_schedules: >
          {{ controller_schedules_all |
          community.general.lists_mergeby(vars['controller_schedules_' + branch_name],
          'name', recursive=true, list_merge='append') }}

This results in the controller_schedules variable the collection needs.

Back