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
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:

View File

@ -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)