Packer.Images/ansible/roles/assets/tasks/containerimages.yml

39 lines
1.6 KiB
YAML
Raw Normal View History

2022-11-28 15:58:56 +00:00
- name: Parse manifests for container images
ansible.builtin.shell:
cmd: cat {{ item.dest }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort -u
register: parsedmanifests
loop: "{{ clusterapi_manifests.results }}"
loop_control:
label: "{{ item.dest | basename }}"
2022-11-07 13:06:34 +00:00
2022-10-17 19:30:06 +00:00
- name: Parse helm charts for container images
ansible.builtin.shell:
cmd: "{{ item.value.helm.parse_logic }}"
chdir: /opt/metacluster/helm-charts/{{ item.key }}
register: containerimages
when: item.value.helm is defined
2022-10-17 19:30:06 +00:00
loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control:
label: "{{ item.key }}"
2022-10-17 19:03:13 +00:00
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
# results: "{{ (containerimages.results | map(attribute='stdout_lines') | select('defined') | flatten }}"
results: "{{ containerimages | json_query('results[*].stdout_lines') | select() | flatten | list }}"
- source: manifests
results: "{{ parsedmanifests | json_query('results[*].stdout_lines') | select() | flatten | list }}"
- 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 }} \
2022-11-17 11:02:27 +00:00
docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}_{{ lookup('ansible.builtin.password', '/dev/null length=5 chars=ascii_lowercase,digits seed={{ item }}') }}.tar:{{ item }}
chdir: /opt/metacluster/container-images
2022-11-28 15:58:56 +00:00
loop: "{{ containerimages_charts + containerimages_manifests + dependencies.container_images | unique }}"