Packer.Images/ansible/roles/metacluster/tasks/components.yml
Danny Bessems 86e99b1515
All checks were successful
continuous-integration/drone/push Build is passing
Install argo-cd;Housekeeping
2022-07-05 09:56:56 +02:00

60 lines
1.9 KiB
YAML

- 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 }}"
- name: Inject chart values into ansible var files
ansible.builtin.blockinfile:
path: /opt/firstboot/ansible/vars/metacluster.yml
block: |
{{ item.key }}:
{{ item.value.helm.chart_values | default(omit) }}
marker: "# {mark} ANSIBLE MANAGED BLOCK -- {{ item.key }}"
loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control:
label: "{{ item.key }}"
- 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.command:
cmd: skopeo copy docker://{{ item }} docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }}
chdir: /opt/metacluster/container-images
register: imagedownload
until: imagedownload is succeeded
retries: 5
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