From 979ac38794f5f21bdb10c55fc7d755b9373397a6 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Tue, 4 Apr 2023 22:44:56 +0200 Subject: [PATCH] Aggregate/store workload cluster chart values --- ansible/roles/assets/tasks/manifests.yml | 25 +++++++++++++------ .../ansible_payload/bootstrap/playbook.yml | 1 + .../roles/workloadcluster/tasks/gitops.yml | 8 ++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ansible/roles/assets/tasks/manifests.yml b/ansible/roles/assets/tasks/manifests.yml index 74240a7..e845e1f 100644 --- a/ansible/roles/assets/tasks/manifests.yml +++ b/ansible/roles/assets/tasks/manifests.yml @@ -8,14 +8,6 @@ loop_control: label: "{{ item.key }}" - # - name: Aggregate chart_values into dict - # ansible.builtin.set_fact: - # workloadcluster_chartvalues: "{{ workloadcluster_chartvalues | default({}) | combine({ (item.key | regex_replace('[^A-Za-z0-9]', '')): { 'chart_values': (item.value.chart_values | from_yaml) } }) }}" - # when: item.value.chart_values is defined - # loop: "{{ lookup('ansible.builtin.dict', downstream.helm_charts) }}" - # loop_control: - # label: "{{ item.key }}" - - name: Write dict to vars_file ansible.builtin.copy: dest: /opt/firstboot/ansible/vars/metacluster.yml @@ -28,6 +20,23 @@ } | to_nice_yaml(indent=2, width=4096) }} + - name: Aggregate chart_values into dict + ansible.builtin.set_fact: + workloadcluster_chartvalues: "{{ workloadcluster_chartvalues | default({}) | combine({ (item.key | regex_replace('[^A-Za-z0-9]', '')): { 'chart_values': (item.value.chart_values | from_yaml) } }) }}" + when: item.value.chart_values is defined + loop: "{{ lookup('ansible.builtin.dict', downstream.helm_charts) }}" + loop_control: + label: "{{ item.key }}" + + - name: Write dict to vars_file + ansible.builtin.copy: + dest: /opt/firstboot/ansible/vars/workloadcluster.yml + content: >- + {{ + { 'downstream_components': ( workloadcluster_chartvalues ) + } | to_nice_yaml(indent=2, width=4096) + }} + - name: Download ClusterAPI manifests ansible.builtin.get_url: url: "{{ item.url }}" diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/playbook.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/playbook.yml index 629a28e..02f94aa 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/playbook.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/playbook.yml @@ -5,6 +5,7 @@ vars_files: - defaults.yml - metacluster.yml + - workloadcluster.yml # become: true roles: - vapp diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml index 72845ea..b20253a 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml @@ -13,6 +13,14 @@ loop_control: label: "{{ item.path | basename }}" +- name: Write chart values to file + ansible.builtin.copy: + dest: /opt/workloadcluster/git-repositories/gitops/values/{{ item.key }}/values.yaml + content: "{{ item.value.chart_values }}" + loop: "{{ lookup('ansible.builtin.dict', downstream_components) }}" + loop_control: + label: "{{ item.key }}" + - name: Initialize/Push git repository ansible.builtin.shell: cmd: |