From c0b2857be1ee54a2499ca50cb4c8da741f4503b8 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Tue, 14 Mar 2023 14:28:24 +0100 Subject: [PATCH] Split CAPI cluster manifest;Remove debugging;Add dependency --- .../workloadcluster/tasks/clusterapi.yml | 23 +++++++++++++++++-- .../common/roles/disks/tasks/main.yml | 2 -- ansible/vars/metacluster.yml | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml index c769603..7c7a4c2 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml @@ -136,11 +136,29 @@ chdir: /opt/metacluster/cluster-api register: clusterctl_newcluster -# TODO: move to git repo +- name: Initialize tempfile + ansible.builtin.tempfile: + state: file + register: capi_clustermanifest + - name: Save workload cluster manifest ansible.builtin.copy: - dest: /opt/metacluster/cluster-api/new-cluster.yaml + dest: "{{ capi_clustermanifest.path }}" content: "{{ clusterctl_newcluster.stdout }}" + +- name: Split manifest into separate files + ansible.builtin.shell: + cmd: >- + kubectl slice \ + -f {{ capi_clustermanifest.path }} \ + -o /opt/metacluster/cluster-api/new-cluster + +- name: Cleanup tempfile + ansible.builtin.file: + path: "{{ capi_clustermanifest.path }}" + state: absent + when: capi_clustermanifest.path is defined + - name: WORKAROUND - Wait for ingress ACME requests to complete ansible.builtin.shell: cmd: >- @@ -151,6 +169,7 @@ until: certificate_subject is not failed retries: "{{ playbook.retries }}" delay: "{{ (storage_benchmark | int) * (playbook.delay.medium | int) }}" + - name: Apply workload cluster manifest kubernetes.core.k8s: definition: >- diff --git a/ansible/roles/firstboot/files/ansible_payload/common/roles/disks/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/common/roles/disks/tasks/main.yml index 7becdbb..c74bcec 100644 --- a/ansible/roles/firstboot/files/ansible_payload/common/roles/disks/tasks/main.yml +++ b/ansible/roles/firstboot/files/ansible_payload/common/roles/disks/tasks/main.yml @@ -27,8 +27,6 @@ - name: Calculate crude storage benchmark ansible.builtin.set_fact: storage_benchmark: "{{ [storage_benchmark, (end_time | int - start_time | int)] | max }}" -- debug: - var: storage_benchmark - name: Mount dynamic disk ansible.posix.mount: diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 63d206a..4b072a6 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -294,6 +294,8 @@ dependencies: url: https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz archive: compressed extra_opts: --strip-components=1 + - filename: kubectl-slice + url: https://github.com/patrickdappollonio/kubectl-slice/releases/download/v1.2.5/kubectl-slice_linux_x86_64.tar.gz - filename: npp-prepper url: https://code.spamasaurus.com/api/packages/djpbessems/generic/npp-prepper/v0.5.1/npp-prepper - filename: skopeo