fix: use shell command for docker pull to get better error messages
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 30s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 23s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 11s
🚀 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 12s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 11m15s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been cancelled
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 30s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 23s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 11s
🚀 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 12s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 11m15s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been cancelled
- Replace docker_image module with shell command for more reliable pulling - Add detailed error output from pull command (stdout/stderr) - Show actual docker pull error messages when pull fails - Simplify pull logic - always attempt pull regardless of local existence
This commit is contained in:
@@ -144,36 +144,30 @@
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Pull Docker image (force pull if not exists locally)
|
||||
community.docker.docker_image:
|
||||
name: "{{ deploy_image }}"
|
||||
source: pull
|
||||
pull: always
|
||||
when:
|
||||
- registry_accessible is defined and registry_accessible == 'true'
|
||||
- image_exists_before_pull.stdout | default('') == 'NOT_FOUND'
|
||||
register: image_pull_result
|
||||
ignore_errors: yes
|
||||
failed_when: false
|
||||
- name: Display image existence check
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
- "Image exists before pull: {{ image_exists_before_pull.stdout | default('unknown') }}"
|
||||
- "Will pull: {{ 'YES' if (image_exists_before_pull.stdout | default('') == 'NOT_FOUND') else 'NO (already exists)' }}"
|
||||
when: registry_accessible is defined and registry_accessible == 'true'
|
||||
|
||||
- name: Pull Docker image (if already exists, just verify)
|
||||
community.docker.docker_image:
|
||||
name: "{{ deploy_image }}"
|
||||
source: pull
|
||||
pull: true
|
||||
- name: Pull Docker image from registry using shell command
|
||||
ansible.builtin.shell: |
|
||||
docker pull {{ deploy_image }} 2>&1
|
||||
when:
|
||||
- registry_accessible is defined and registry_accessible == 'true'
|
||||
- image_exists_before_pull.stdout | default('') != 'NOT_FOUND'
|
||||
register: image_pull_result
|
||||
ignore_errors: yes
|
||||
failed_when: false
|
||||
changed_when: image_pull_result.rc == 0
|
||||
|
||||
- name: Display pull result
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
- "Pull result: {{ image_pull_result | default('not executed') }}"
|
||||
- "Pull failed: {{ image_pull_result.failed | default(false) }}"
|
||||
- "Pull changed: {{ image_pull_result.changed | default(false) }}"
|
||||
- "Pull command exit code: {{ image_pull_result.rc | default('unknown') }}"
|
||||
- "Pull stdout: {{ image_pull_result.stdout | default('none') }}"
|
||||
- "Pull stderr: {{ image_pull_result.stderr | default('none') }}"
|
||||
- "Pull succeeded: {{ 'YES' if (image_pull_result.rc | default(1) == 0) else 'NO' }}"
|
||||
when: registry_accessible is defined and registry_accessible == 'true'
|
||||
|
||||
- name: Verify image exists locally after pull
|
||||
@@ -205,11 +199,19 @@
|
||||
msg: |
|
||||
Failed to pull image {{ deploy_image }} from registry.
|
||||
The image does not exist locally after pull attempt.
|
||||
Pull result: changed={{ image_pull_result.changed | default(false) }}, failed={{ image_pull_result.failed | default(false) }}
|
||||
|
||||
Pull command result:
|
||||
- Exit code: {{ image_pull_result.rc | default('unknown') }}
|
||||
- Stdout: {{ image_pull_result.stdout | default('none') }}
|
||||
- Stderr: {{ image_pull_result.stderr | default('none') }}
|
||||
|
||||
Image check result: {{ image_check.stdout | default('unknown') }}
|
||||
|
||||
Please check:
|
||||
1. Does the image exist in {{ source_registry }}?
|
||||
2. Are registry credentials correct?
|
||||
3. Is the registry accessible?
|
||||
4. Check the pull command output above for specific error messages.
|
||||
when:
|
||||
- registry_accessible is defined and registry_accessible == 'true'
|
||||
- (image_check.stdout | default('') == 'NOT_FOUND' or image_check.stdout | default('') == '')
|
||||
|
||||
Reference in New Issue
Block a user