Add retries to preflight check;Move/refactor tasks to front
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Danny Bessems 2023-01-31 13:42:26 +01:00
parent c793ced9f3
commit e5908fde1c
3 changed files with 49 additions and 18 deletions

View File

@ -53,3 +53,29 @@
- name: Update certificate truststore - name: Update certificate truststore
ansible.builtin.command: ansible.builtin.command:
cmd: update-ca-certificates cmd: update-ca-certificates
- name: Get all stored fully qualified container image names
ansible.builtin.shell:
cmd: >-
skopeo list-tags \
--insecure-policy \
docker-archive:./{{ item | basename }} | \
jq -r '.Tags[0]'
chdir: /opt/metacluster/container-images
register: registry_artifacts
loop: "{{ query('ansible.builtin.fileglob', '/opt/metacluster/container-images/*.tar') }}"
- name: Get source registries of all artifacts
ansible.builtin.set_fact:
source_registries: "{{ (source_registries | default([]) + [(item | split('/'))[0]]) | unique | sort }}"
loop: "{{ registry_artifacts | json_query('results[*].stdout') | select() }}"
- name: Configure K3s node for private registry
ansible.builtin.template:
dest: /etc/rancher/k3s/registries.yaml
src: registries.j2
vars:
_template:
data: "{{ source_registries }}"
hv:
fqdn: "{{ vapp['metacluster.fqdn'] }}"

View File

@ -43,26 +43,26 @@
delay: "{{ playbook.delays.short }}" delay: "{{ playbook.delays.short }}"
until: push_result is not failed until: push_result is not failed
- name: Get all stored container images (=artifacts) # - name: Get all stored container images (=artifacts)
ansible.builtin.uri: # ansible.builtin.uri:
url: https://registry.{{ vapp['metacluster.fqdn'] }}/api/v2.0/search?q=library # url: https://registry.{{ vapp['metacluster.fqdn'] }}/api/v2.0/search?q=library
method: GET # method: GET
register: registry_artifacts # register: registry_artifacts
- name: Get source registries of all artifacts # - name: Get source registries of all artifacts
ansible.builtin.set_fact: # ansible.builtin.set_fact:
source_registries: "{{ (source_registries | default([]) + [(item | split('/'))[1]]) | unique | sort }}" # source_registries: "{{ (source_registries | default([]) + [(item | split('/'))[1]]) | unique | sort }}"
loop: "{{ registry_artifacts.json.repository | json_query('[*].repository_name') }}" # loop: "{{ registry_artifacts.json.repository | json_query('[*].repository_name') }}"
- name: Configure K3s node for private registry # - name: Configure K3s node for private registry
ansible.builtin.template: # ansible.builtin.template:
dest: /etc/rancher/k3s/registries.yaml # dest: /etc/rancher/k3s/registries.yaml
src: registries.j2 # src: registries.j2
vars: # vars:
_template: # _template:
data: "{{ source_registries }}" # data: "{{ source_registries }}"
hv: # hv:
fqdn: "{{ vapp['metacluster.fqdn'] }}" # fqdn: "{{ vapp['metacluster.fqdn'] }}"
module_defaults: module_defaults:
ansible.builtin.uri: ansible.builtin.uri:

View File

@ -4,3 +4,8 @@
method: GET method: GET
validate_certs: no validate_certs: no
status_code: [200, 401] status_code: [200, 401]
register: api_readycheck
until:
- api_readycheck.json.apiVersion is defined
retries: "{{ playbook.retries }}"
delay: "{{ playbook.delays.medium }}"