Add eda capability to an ogranization (automated)

As we have automated almost everything, we don't want to start now, adding files by hand. We created a playbook to add this capability to a organization without lifting a finger.

All we need to do, is run the playbook and teel the playbook to wich organization the files must be added.
The playbbok does the heavy lifting.

the repository

The repository for this play looks like this:

.
├── env_vars.yml
├── gitlab_get_api_token.yml
├── main.yml
├── README.md
└── templates
    ├── eda_controller_tokens.yml.j2
    ├── eda_credemtials.yml.j2
    ├── eda_decision_environments.yml.j2
    ├── eda_event_streams.yml.j2
    ├── eda_projects.yml.j2
    ├── eda_rulebook_activations.yml.j2
    ├── main.yml.j2
    └── stop_running_rulebooks.yml

Steps

When the main.yml is started, it will perform a number of actions:
- Checkout the existing config as code repository for the organization - Add new files for EDA config as code - Replace existing playbook main.yml - Add support playbook - create new branch and push the repository - create a merge request and run the pipeline into development

After running this play, the organization can start adding their event driven automations as configuration as code into the rhaap platform.

Files

To make this automation possible, we need a number of variable defined, these are gathered in the file:

env_vars.yml

This file is a subset of the variable file that is used in the 'Add organization automated' chapter. The same variables will be needed here, in a later stage we will ook into this to reduce the doubling of these variables. For now, we need them here..

The organization_short_name value needs to be passed to the play as 'extra_vars'.

---
organization_long_name: 'org_{{ organization_short_name }}'
gitlab_protocol: 'https://'
gitlab_url: 'gitlab.homelab/'
gitlab_group: 'cac_26'
gitlab_default_branch: dev
gitlab_validate_certs: false
team_project_name: "rhaap_cac_{{ organization_long_name | lower }}"
aap_env:
  dev:
    rhaap_hostname: rhaap_dev.homelab
  prod:
    rhaap_hostname: rhaap_prod.homelab
code_environment_vars:
  all:
  dev:
  prod:

gitlab_get_api_token.yml

This play is used in several plays and creates a session token to gitlab, this token is then used for checking the pipeline status.

- name: GitLab Post | Obtain Access Token
  ansible.builtin.uri:
    url: "{{ gitlab_protocol }}{{ gitlab_url }}oauth/token"
    method: POST
    validate_certs: false
    body_format: json
    headers:
      Content-Type: application/json
    body: >
      {
        "grant_type": "password",
        "username": "{{ gitlab_user_username }}",
        "password": "{{ gitlab_user_password }}"
      }
  register: gitlab_access_token
  no_log: true

- name: Store the token in var
  ansible.builtin.set_fact:
    token: "{{ gitlab_access_token.json.access_token }}"
  no_log: true

The main playbook that wil add the files:
main.yml

The templates used to create the files: