From 806bf24fc01f10c49fe81522475f52dce8612f5d Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Sun, 6 Nov 2022 13:23:14 +0100 Subject: [PATCH] Pin version;Store manifests in folder structure --- .../roles/metacluster/tasks/components.yml | 65 ++++++++++++------- ansible/vars/metacluster.yml | 6 ++ 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index af5b803..11fe5af 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -4,7 +4,10 @@ state: directory loop: - /opt/metacluster/helm-charts - - /opt/metacluster/manifests + - /opt/metacluster/manifests/bootstrap-kubeadm/{{ components.cluster-api.manifest.version.base }} + - /opt/metacluster/manifests/cluster-api/{{ components.cluster-api.manifest.version.base }} + - /opt/metacluster/manifests/control-plane-kubeadm/{{ components.cluster-api.manifest.version.base }} + - /opt/metacluster/manifests/infrastructure-vsphere/{{ components.cluster-api.manifest.version.infrastructure-vsphere }} - /opt/metacluster/container-images - name: Add helm repositories @@ -18,6 +21,7 @@ ansible.builtin.command: cmd: helm fetch {{ item.value.helm.chart }} --untar --version {{ item.value.helm.version }} chdir: /opt/metacluster/helm-charts + when: item.value.helm is defined loop: "{{ lookup('ansible.builtin.dict', components) }}" loop_control: label: "{{ item.key }}" @@ -39,31 +43,48 @@ - block: - - name: Lookup ClusterAPI manifests - ansible.builtin.shell: - cmd: clusterctl config repositories | awk '/CoreProvider|kubeadm|vsphere/ {print $(NF-1)"download/"$NF}' - register: clusterapi_manifests - - - name: Download manifests + - name: Download ClusterAPI manifests ansible.builtin.get_url: - url: "{{ item }}" - dest: "/opt/metacluster/manifests/{{ item | basename }}" - loop: "{{ clusterapi_manifests.stdout_lines }}" + url: https://github.com/kubernetes-sigs/{{ item.url }} + dest: /opt/metacluster/manifests/{{ item.dest }} + register: clusterapi_manifests + loop: + # This list is based on `clusterctl config repositories` + # Note: Each manifest also needs a metadata.yaml file stored in the respective folder + - url: cluster-api/releases/{{ components.cluster-api.manifest.version.base }}/download/bootstrap-components.yaml + dest: bootstrap-kubeadm/{{ components.cluster-api.manifest.version.base }}/bootstrap-components.yaml + - url: cluster-api/releases/{{ components.cluster-api.manifest.version.base }}/download/core-components.yaml + dest: cluster-api/{{ components.cluster-api.manifest.version.base }}/core-components.yaml + - url: cluster-api/releases/{{ components.cluster-api.manifest.version.base }}/download/control-plane-components.yaml + dest: control-plane-kubeadm/{{ components.cluster-api.manifest.version.base }}/control-plane-components.yaml + - url: cluster-api-provider-vsphere/releases/{{ components.cluster-api.manifest.version.infrastructure-vsphere }}/download/infrastructure-components.yaml + dest: infrastructure-vsphere/{{ components.cluster-api.manifest.version.infrastructure-vsphere }}/infrastructure-components.yaml + - url: cluster-api-provider-vsphere/releases/{{ components.cluster-api.manifest.version.infrastructure-vsphere }}/download/metadata.yaml + dest: infrastructure-vsphere/{{ components.cluster-api.manifest.version.infrastructure-vsphere }}/metadata.yaml + # This downloads the same metadata.yaml file to three separate folders + - url: cluster-api/releases/{{ components.cluster-api.manifest.version.base }}/download/metadata.yaml + dest: bootstrap-kubeadm/{{ components.cluster-api.manifest.version.base }}/metadata.yaml + - url: cluster-api/releases/{{ components.cluster-api.manifest.version.base }}/download/metadata.yaml + dest: cluster-api/{{ components.cluster-api.manifest.version.base }}/metadata.yaml + - url: cluster-api/releases/{{ components.cluster-api.manifest.version.base }}/download/metadata.yaml + dest: control-plane-kubeadm/{{ components.cluster-api.manifest.version.base }}/metadata.yaml loop_control: - label: "{{ item | basename }}" + label: "{{ item.url | basename }}" - - name: Parse manifests - ansible.builtin.shell: - cmd: cat {{ item | basename }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort - chdir: /opt/metacluster/manifests - register: parsedmanifests - loop: "{{ clusterapi_manifests.stdout_lines | sort }}" - loop_control: - label: "{{ item | basename }}" + - debug: + var: clusterapi_manifests + # - name: Parse manifests + # ansible.builtin.shell: + # cmd: cat {{ item | basename }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort + # chdir: /opt/metacluster/manifests + # register: parsedmanifests + # loop: "{{ clusterapi_manifests.stdout_lines | sort }}" + # loop_control: + # label: "{{ item | basename }}" - - name: Store container images - ansible.builtin.set_fact: - clusterapi_containerimages: "{{ parsedmanifests | json_query('results[*].stdout') }}" + # - name: Store container images + # ansible.builtin.set_fact: + # clusterapi_containerimages: "{{ parsedmanifests | json_query('results[*].stdout') }}" - name: Parse helm charts for container images ansible.builtin.shell: diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index d30300e..26e2676 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -76,6 +76,12 @@ components: # chart_values: !unsafe | # installCRDs: true + cluster-api: + manifest: + version: + base: v1.2.4 + infrastructure-vsphere: v1.3.5 + gitea: helm: version: v6.0.0 # (= Gitea v1.17.1)