Pin version;Store manifests in folder structure
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2022-11-06 13:23:14 +01:00
parent 4733d8e5f8
commit 806bf24fc0
2 changed files with 49 additions and 22 deletions

View File

@ -4,7 +4,10 @@
state: directory state: directory
loop: loop:
- /opt/metacluster/helm-charts - /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 - /opt/metacluster/container-images
- name: Add helm repositories - name: Add helm repositories
@ -18,6 +21,7 @@
ansible.builtin.command: ansible.builtin.command:
cmd: helm fetch {{ item.value.helm.chart }} --untar --version {{ item.value.helm.version }} cmd: helm fetch {{ item.value.helm.chart }} --untar --version {{ item.value.helm.version }}
chdir: /opt/metacluster/helm-charts chdir: /opt/metacluster/helm-charts
when: item.value.helm is defined
loop: "{{ lookup('ansible.builtin.dict', components) }}" loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
@ -39,31 +43,48 @@
- block: - block:
- name: Lookup ClusterAPI manifests - name: Download ClusterAPI manifests
ansible.builtin.shell:
cmd: clusterctl config repositories | awk '/CoreProvider|kubeadm|vsphere/ {print $(NF-1)"download/"$NF}'
register: clusterapi_manifests
- name: Download manifests
ansible.builtin.get_url: ansible.builtin.get_url:
url: "{{ item }}" url: https://github.com/kubernetes-sigs/{{ item.url }}
dest: "/opt/metacluster/manifests/{{ item | basename }}" dest: /opt/metacluster/manifests/{{ item.dest }}
loop: "{{ clusterapi_manifests.stdout_lines }}" 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: loop_control:
label: "{{ item | basename }}" label: "{{ item.url | basename }}"
- name: Parse manifests - debug:
ansible.builtin.shell: var: clusterapi_manifests
cmd: cat {{ item | basename }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort # - name: Parse manifests
chdir: /opt/metacluster/manifests # ansible.builtin.shell:
register: parsedmanifests # cmd: cat {{ item | basename }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort
loop: "{{ clusterapi_manifests.stdout_lines | sort }}" # chdir: /opt/metacluster/manifests
loop_control: # register: parsedmanifests
label: "{{ item | basename }}" # loop: "{{ clusterapi_manifests.stdout_lines | sort }}"
# loop_control:
# label: "{{ item | basename }}"
- name: Store container images # - name: Store container images
ansible.builtin.set_fact: # ansible.builtin.set_fact:
clusterapi_containerimages: "{{ parsedmanifests | json_query('results[*].stdout') }}" # clusterapi_containerimages: "{{ parsedmanifests | json_query('results[*].stdout') }}"
- name: Parse helm charts for container images - name: Parse helm charts for container images
ansible.builtin.shell: ansible.builtin.shell:

View File

@ -76,6 +76,12 @@ components:
# chart_values: !unsafe | # chart_values: !unsafe |
# installCRDs: true # installCRDs: true
cluster-api:
manifest:
version:
base: v1.2.4
infrastructure-vsphere: v1.3.5
gitea: gitea:
helm: helm:
version: v6.0.0 # (= Gitea v1.17.1) version: v6.0.0 # (= Gitea v1.17.1)