main.yml.txt

Template main.yml that will be copied into the new repository to be run as the pipeline runs after an update in the repository.
This main.yml will configure the changes made into the new repository into the designated rhaap environment, after being triggered from the pipeline.

---
- name: Configure rhaap platform controller for MGT
  hosts: "{{ instance | default('localhost') }}"
  connection: local
  gather_facts: false

  pre_tasks:

    - name: Get secrets
      community.hashi_vault.vault_kv2_get:
        url: 'http://openbao.prod.lab:8200'
        token: "{{ vault_token }}"
        namespace: "{{ branch_name }}/{{ org_name }}"
        engine_mount_point: kv
        path: "rhaap_admin"
      register: secrets
      no_log: true

    - name: Set rhaap facts
      ansible.builtin.set_fact:
        aap_hostname: "{{ secrets['secret']['hostname'] }}"
        aap_username: "{{ secrets['secret']['username'] }}"
        aap_password: "{{ secrets['secret']['password'] }}"
        aap_validate_certs: "{{ secrets['secret']['validate_certs'] }}"
      no_log: true

    - name: Set the vars
      ansible.builtin.set_fact:
        aap_configuration_secure_logging: false

    - name: Find var files for controller and eda
      ansible.builtin.find:
        paths: "group_vars/{{ branch_name }}"
        patterns:
          - 'controller_*.yml'
          - 'eda_*.yml'
      register: _ctl_files

    - name: Create the vaiables for configuration as code
      ansible.builtin.set_fact:
        "{{ ((filectlr.path | split('/'))[2] | split('.'))[0] }}": |
          {{ vars[(((filectlr.path | split('/'))[2] | split('.'))[0]) + '_all'] | list +
          vars[(((filectlr.path | split('/'))[2] | split('.'))[0]) + '_' + branch_name] | list }}
      loop: "{{ _ctl_files.files }}"
      loop_control:
        loop_var: filectlr
        label: "{{ filectlr.path }}"

  roles:
    - infra.aap_configuration.dispatch

Back