- name: Create folder structure(s) ansible.builtin.file: path: "{{ item }}" state: directory loop: - /opt/metacluster/helm-charts - /opt/metacluster/container-images - name: Add helm repositories kubernetes.core.helm_repository: 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 }}" - block: - name: Aggregate chart_values into dict ansible.builtin.set_fact: chart_values: "{{ chart_values | default({}) | combine({ item.key: { 'chart_values': item.value.helm.chart_values } }) }}" when: item.value.helm.chart_values is defined loop: "{{ lookup('ansible.builtin.dict', components) }}" loop_control: label: "{{ item.key }}" - ansible.builtin.debug: msg: "{{ chart_values | to_nice_yaml(default_style='\"', indent=2, width=4096) }}" - name: Write dict to vars_file ansible.builtin.blockinfile: path: /opt/firstboot/ansible/vars/metacluster.yml block: "{{ { 'components': chart_values } | to_nice_yaml(default_style='\"', indent=2, width=4096) }}" - 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 loop: "{{ lookup('ansible.builtin.dict', components) }}" loop_control: label: "{{ item.key }}" - name: Pull and store containerimages ansible.builtin.shell: cmd: >- skopeo copy \ --retry-times=5 \ docker://{{ item }} \ docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }} chdir: /opt/metacluster/container-images loop: "{{ containerimages.results | map(attribute='stdout_lines') | flatten + dependencies.container_images }}" - name: Compress tarballs community.general.archive: dest: /opt/metacluster/container-images/image-tarballs.tgz path: /opt/metacluster/container-images/* format: gz remove: yes