2022-11-28 15:58:56 +00:00
|
|
|
- name: Parse manifests for container images
|
|
|
|
ansible.builtin.shell:
|
2022-12-30 10:14:49 +00:00
|
|
|
# This set of commands is necessary to deal with multi-line scalar values
|
|
|
|
# eg.:
|
|
|
|
# key: |
|
|
|
|
# multi-line
|
|
|
|
# value
|
|
|
|
cmd: >-
|
|
|
|
cat {{ item.dest }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /';
|
|
|
|
cat {{ item.dest }} | yq eval '.data.data' | yq --no-doc eval '.. | .image? | select(.)';
|
|
|
|
cat {{ item.dest }} | yq --no-doc eval '.. | .files? | with_entries(select(.value.path == "*.yaml")).[0].content' | awk '!/null/' | yq eval '.. | .image? | select(.)'
|
2022-11-28 15:58:56 +00:00
|
|
|
register: parsedmanifests
|
|
|
|
loop: "{{ clusterapi_manifests.results }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.dest | basename }}"
|
2022-11-07 13:06:34 +00:00
|
|
|
|
2023-03-28 11:49:18 +00:00
|
|
|
- name: Parse metacluster helm charts for container images
|
2022-10-17 19:30:06 +00:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "{{ item.value.helm.parse_logic }}"
|
|
|
|
chdir: /opt/metacluster/helm-charts/{{ item.key }}
|
2023-03-28 11:49:18 +00:00
|
|
|
register: chartimages_metacluster
|
2022-11-07 03:18:20 +00:00
|
|
|
when: item.value.helm is defined
|
2023-04-05 11:37:31 +00:00
|
|
|
loop: "{{ query('ansible.builtin.dict', components) }}"
|
2022-10-17 19:30:06 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
2022-10-17 19:03:13 +00:00
|
|
|
|
2023-03-28 11:49:18 +00:00
|
|
|
- name: Parse workloadcluster helm charts for container images
|
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "{{ item.value.parse_logic }}"
|
2023-04-04 15:22:39 +00:00
|
|
|
chdir: /opt/workloadcluster/helm-charts/{{ item.value.namespace }}/{{ item.key }}
|
2023-03-28 11:49:18 +00:00
|
|
|
register: chartimages_workloadcluster
|
2023-04-05 11:37:31 +00:00
|
|
|
loop: "{{ query('ansible.builtin.dict', downstream.helm_charts) }}"
|
2023-03-28 11:49:18 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
|
|
|
|
2022-11-28 15:58:56 +00:00
|
|
|
- name: Store container images in dicts
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
containerimages_{{ item.source }}: "{{ item.results }}"
|
|
|
|
loop:
|
|
|
|
- source: charts
|
2023-03-28 11:49:18 +00:00
|
|
|
results: "{{ (chartimages_metacluster | json_query('results[*].stdout_lines')) + (chartimages_workloadcluster | json_query('results[*].stdout_lines')) | select() | flatten | list }}"
|
2022-12-31 12:11:33 +00:00
|
|
|
- source: kubeadm
|
2023-01-01 02:33:58 +00:00
|
|
|
results: "{{ kubeadmimages.stdout_lines }}"
|
2022-11-28 15:58:56 +00:00
|
|
|
- source: manifests
|
|
|
|
results: "{{ parsedmanifests | json_query('results[*].stdout_lines') | select() | flatten | list }}"
|
2022-11-29 10:24:26 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.source }}"
|
2022-11-28 15:58:56 +00:00
|
|
|
|
2023-03-09 11:45:51 +00:00
|
|
|
- name: Log in to container registry
|
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: >-
|
|
|
|
skopeo login \
|
|
|
|
docker.io \
|
|
|
|
--username={{ docker_username }} \
|
|
|
|
--password={{ docker_password }}
|
|
|
|
no_log: true
|
|
|
|
|
2022-06-29 11:07:34 +00:00
|
|
|
- name: Pull and store containerimages
|
2022-07-06 14:32:39 +00:00
|
|
|
ansible.builtin.shell:
|
2022-07-06 12:36:30 +00:00
|
|
|
cmd: >-
|
|
|
|
skopeo copy \
|
2022-07-27 12:23:33 +00:00
|
|
|
--insecure-policy \
|
2022-07-06 14:09:21 +00:00
|
|
|
--retry-times=5 \
|
2022-07-06 12:36:30 +00:00
|
|
|
docker://{{ item }} \
|
2023-07-11 09:41:33 +00:00
|
|
|
oci-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}_{{ lookup('ansible.builtin.password', '/dev/null length=5 chars=ascii_lowercase,digits seed={{ item }}') }}.tar:{{ item }}
|
2022-06-29 11:07:34 +00:00
|
|
|
chdir: /opt/metacluster/container-images
|
2023-01-02 13:39:01 +00:00
|
|
|
loop: "{{ (containerimages_charts + containerimages_kubeadm + containerimages_manifests + dependencies.container_images) | flatten | unique | sort }}"
|