fix: Improve registry check and image pull error handling
Some checks failed
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 33s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 15s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 14s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 1m11s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 32s
Some checks failed
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 33s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 15s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 14s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 1m11s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 32s
- Add registry_accessible flag to safely check registry status - Fix 'argument of type bool is not iterable' error in when conditions - Only pull image if registry is accessible - Add ignore_errors to image pull task to prevent failures - Improves handling of registry connectivity issues
This commit is contained in:
@@ -53,6 +53,15 @@
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
become: no
|
||||
|
||||
- name: Set registry accessible flag
|
||||
ansible.builtin.set_fact:
|
||||
registry_accessible: >-
|
||||
{%- if registry_check.status is defined and registry_check.status | int in [200, 401] -%}
|
||||
true
|
||||
{%- else -%}
|
||||
false
|
||||
{%- endif -%}
|
||||
|
||||
- name: Login to Docker registry
|
||||
community.docker.docker_login:
|
||||
registry_url: "{{ docker_registry }}"
|
||||
@@ -60,7 +69,7 @@
|
||||
password: "{{ registry_password }}"
|
||||
when:
|
||||
- registry_password | string | trim != ''
|
||||
- registry_check.status | default(0) in [200, 401]
|
||||
- registry_accessible | bool
|
||||
no_log: yes
|
||||
ignore_errors: yes
|
||||
register: docker_login_result
|
||||
@@ -70,8 +79,10 @@
|
||||
name: "{{ deploy_image }}"
|
||||
source: pull
|
||||
pull: true
|
||||
when: registry_accessible | bool
|
||||
register: image_pull_result
|
||||
failed_when: image_pull_result.failed | default(false)
|
||||
ignore_errors: yes
|
||||
failed_when: false
|
||||
|
||||
- name: Verify image exists locally
|
||||
community.docker.docker_image_info:
|
||||
|
||||
Reference in New Issue
Block a user