From 002031aefacd2540405dc7bfc0a938ce798a3ab5 Mon Sep 17 00:00:00 2001 From: harishsurf Date: Fri, 31 May 2024 12:49:49 +0000 Subject: [PATCH] Force pull quay image even if already present (for debugging only) --- .../tasks/install-quay-service.yaml | 18 +++++++++---- .../mirror_appliance/tasks/wait-for-quay.yaml | 25 +++++++++++++++++++ .../templates/quay.service.j2 | 2 +- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ansible-runner/context/app/project/roles/mirror_appliance/tasks/install-quay-service.yaml b/ansible-runner/context/app/project/roles/mirror_appliance/tasks/install-quay-service.yaml index 1128ef0..10471f2 100755 --- a/ansible-runner/context/app/project/roles/mirror_appliance/tasks/install-quay-service.yaml +++ b/ansible-runner/context/app/project/roles/mirror_appliance/tasks/install-quay-service.yaml @@ -121,17 +121,25 @@ src: ../templates/quay.service.j2 dest: "{{ systemd_unit_dir }}/quay-app.service" -- name: Check if Quay image is loaded - command: podman inspect --type=image {{ quay_image }} - register: q - ignore_errors: yes +# - name: Check if Quay image is loaded +# command: podman inspect --type=image {{ quay_image }} +# register: q +# ignore_errors: yes + +# - name: Pull Quay image +# containers.podman.podman_image: +# name: "{{ quay_image }}" +# when: q.rc != 0 +# retries: 5 +# delay: 5 - name: Pull Quay image containers.podman.podman_image: name: "{{ quay_image }}" - when: q.rc != 0 retries: 5 delay: 5 + register: result + until: result is succeeded - name: Create Quay Storage named volume containers.podman.podman_volume: diff --git a/ansible-runner/context/app/project/roles/mirror_appliance/tasks/wait-for-quay.yaml b/ansible-runner/context/app/project/roles/mirror_appliance/tasks/wait-for-quay.yaml index 755840e..4e66465 100644 --- a/ansible-runner/context/app/project/roles/mirror_appliance/tasks/wait-for-quay.yaml +++ b/ansible-runner/context/app/project/roles/mirror_appliance/tasks/wait-for-quay.yaml @@ -22,3 +22,28 @@ - name: Fail the playbook due to Quay not becoming alive fail: msg: "Quay did not become alive. Check debug logs above for details." + + - name: Check if quay-app container log file exists + stat: + path: "/run/systemd/%n-quaypodlogs.log" + register: quay_log_file + + - name: Read quay-app container log file + slurp: + src: "/run/systemd/%n-quaypodlogs.log" + register: quay_log_content + when: quay_log_file.stat.exists + + - name: Debug quay-app container log content + debug: + msg: "{{ quay_log_content.content | b64decode }}" + when: quay_log_file.stat.exists + + - name: Retrieve Podman logs for quay-app container + command: podman logs quay-app + register: podman_logs + ignore_errors: yes + + - name: Debug Podman logs output + debug: + var: podman_logs.stdout_lines diff --git a/ansible-runner/context/app/project/roles/mirror_appliance/templates/quay.service.j2 b/ansible-runner/context/app/project/roles/mirror_appliance/templates/quay.service.j2 index 2ab04dc..92933af 100755 --- a/ansible-runner/context/app/project/roles/mirror_appliance/templates/quay.service.j2 +++ b/ansible-runner/context/app/project/roles/mirror_appliance/templates/quay.service.j2 @@ -22,7 +22,7 @@ ExecStart=/usr/bin/podman run \ {{ quay_image }} ExecStop=-/usr/bin/podman stop --ignore --cidfile %t/%n-cid -t 10 -ExecStopPost=-/usr/bin/podman rm --ignore -f --cidfile %t/%n-cid +ExecStopPost=-/usr/bin/podman logs --cidfile %t/%n-cid > %t/%n-quaypodlogs.log PIDFile=%t/%n-pid KillMode=none Restart=always