From 03affc87cff2ba1abadbf37f3e91de2f7ebd73f2 Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Sun, 9 Nov 2025 00:57:08 +0100 Subject: [PATCH] fix: use shell command for docker pull to get better error messages - 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 --- deployment/ansible/playbooks/deploy-image.yml | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/deployment/ansible/playbooks/deploy-image.yml b/deployment/ansible/playbooks/deploy-image.yml index ba79d0e1..d75694f4 100644 --- a/deployment/ansible/playbooks/deploy-image.yml +++ b/deployment/ansible/playbooks/deploy-image.yml @@ -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('') == '')