Download ClusterAPI assets
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2022-10-17 11:13:13 +02:00
parent 204faa7415
commit 67676ff03b
2 changed files with 26 additions and 2 deletions

View File

@ -4,6 +4,7 @@
state: directory state: directory
loop: loop:
- /opt/metacluster/helm-charts - /opt/metacluster/helm-charts
- /opt/metacluster/manifests
- /opt/metacluster/container-images - /opt/metacluster/container-images
- name: Add helm repositories - name: Add helm repositories
@ -45,6 +46,29 @@
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- block:
- name: Retrieve Cluster-API manifests
ansible.builtin.command:
cmd: clusterctl config repositories | awk '/CoreProvider|kubeadm|vsphere/ {print $(NF-1)"download/"$NF}'
register: clusterapi_manifests
- name: Download manifests
ansible.builtin.get_url:
url: "{{ item }}"
dest: "/opt/metacluster/manifests/{{ item | basename }}"
loop: "{{ clusterapi_manifests.stdout_lines }}"
- name: Parse manifests
ansible.builtin.shell:
cmd: cat {{ item }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort
register: parsedmanifests
loop: "{{ query('ansible.builtin.fileglob', '/opt/metacluster/manifests/*.yaml') | sort }}"
- name: Store container images
ansible.builtin.set_fact:
clusterapi_containerimages: parsedmanifests.results | json_query('results[*].stdout')
- name: Pull and store containerimages - name: Pull and store containerimages
ansible.builtin.shell: ansible.builtin.shell:
cmd: >- cmd: >-
@ -54,7 +78,7 @@
docker://{{ item }} \ docker://{{ item }} \
docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }} docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }}
chdir: /opt/metacluster/container-images chdir: /opt/metacluster/container-images
loop: "{{ ((containerimages.results | map(attribute='stdout_lines') | flatten) + dependencies.container_images) | unique }}" loop: "{{ ((containerimages.results | map(attribute='stdout_lines') | flatten) + dependencies.container_images + clusterapi_containerimages) | unique }}"
# - name: Inject manifests # - name: Inject manifests
# ansible.builtin.template: # ansible.builtin.template:

View File

@ -189,7 +189,7 @@ dependencies:
static_binaries: static_binaries:
- filename: clusterctl - filename: clusterctl
url: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.2/clusterctl-linux-amd64 url: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.3/clusterctl-linux-amd64
- filename: govc - filename: govc
url: https://github.com/vmware/govmomi/releases/download/v0.29.0/govc_Linux_x86_64.tar.gz url: https://github.com/vmware/govmomi/releases/download/v0.29.0/govc_Linux_x86_64.tar.gz
archive: compressed archive: compressed