Packer.Images/ansible/roles/metacluster/tasks/components.yml

45 lines
1.4 KiB
YAML
Raw Normal View History

- name: Create folder structure(s)
ansible.builtin.file:
path: "{{ item }}"
state: directory
loop:
- /opt/metacluster/helm-charts
2022-06-26 16:24:57 +00:00
- /opt/metacluster/container-images
- name: Add helm repositories
kubernetes.core.helm_repository:
2022-06-24 22:54:36 +00:00
name: "{{ item.name }}"
repo_url: "{{ item.url }}"
state: present
loop: "{{ platform.helm_repositories }}"
- name: Fetch helm charts
ansible.builtin.command:
cmd: helm fetch {{ item.value.helm.chart }} --untar --version {{ item.value.helm.version }}
chdir: /opt/metacluster/helm-charts
loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control:
label: "{{ item.key }}"
2022-06-26 16:24:57 +00:00
- name: Parse helm charts for container images
2022-06-27 07:56:48 +00:00
ansible.builtin.shell:
2022-06-27 10:27:11 +00:00
cmd: "{{ item.value.helm.parse_logic }}"
2022-06-27 17:43:07 +00:00
chdir: /opt/metacluster/helm-charts/{{ item.key }}
2022-06-26 16:24:57 +00:00
register: containerimages
loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control:
label: "{{ item.key }}"
- name: Pull and store containerimages
ansible.builtin.command:
cmd: skopeo copy docker://{{ item }} docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }}
chdir: /opt/metacluster/container-images
loop: "{{ containerimages.results | map(attribute='stdout_lines') | flatten }}"
2022-06-26 16:32:05 +00:00
- name: Compress tarballs
community.general.archive:
dest: /opt/metacluster/container-images/image-tarballs.tgz
path: /opt/metacluster/container-images/*
format: gz
remove: yes