eda_credential_types.yml

In these files we configure the credential types for eda controller.
we will probably do this on the global configuration (ALL).

variables

The api understands the following structure:

{
    "name": "",
    "description": "",
    "inputs": {},
    "injectors": {}
}

Below you can see examples of how this is used.

group_vars/all/eda_credential_types.yml

Here we see an example of the configuration for a credential type to pull items from automation hub.

---
eda_credential_types_all:

  - name: REST API Credential
    description: REST API Credential
    inputs:
      fields:
        - type: string
          id: rest_username
          label: REST Username
        - secret: true
          type: string
          id: rest_password
          label: REST Password
      required:
        - rest_username
        - rest_password
    injectors:
      extra_vars:
        rest_password: !unsafe "{{ rest_password }}"
        rest_username: !unsafe "{{ rest_username }}"
      env:
        rest_username_env: !unsafe "{{ rest_username }}"
        rest_password_env: !unsafe "{{ rest_password }}"
...

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/eda_credential_types.yml

As we do not configure extra credential_types in development, this file is an empty set.

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

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

group_vars/prod/eda_credential_types.yml

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

---
eda_credential_types_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: - eda_credential_types_all
- eda_credential_types_

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

This results in the controller_credential_types variable the collection needs.

Back