From c076f60b5edd83ab344aee16fb51c9db98d6cc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20-=20Le=20Filament?= <theo@le-filament.com> Date: Mon, 18 Dec 2023 16:51:28 +0100 Subject: [PATCH] change: inform user if image on test and prod differ --- tasks/instance.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tasks/instance.yml b/tasks/instance.yml index adda1b6..1d3d95d 100644 --- a/tasks/instance.yml +++ b/tasks/instance.yml @@ -110,13 +110,23 @@ - name: Get image from another instance when: item.value.image_instance | default(false) != item.key block: - - name: Check if instance image exists + - name: Check if destination instance image exists community.docker.docker_image_info: name: "filament/{{ item.key }}:{{ instance_odoo_setup.odoo_version }}" - register: prod_image + register: dst_image + + - name: Check if source instance image exists + community.docker.docker_image_info: + name: "filament/{{ item.value.image_instance }}:{{ instance_odoo_setup.odoo_version }}" + register: src_image + + - name: Copy image from {{ item.value.image_instance }} to {{ item.key }} may be needed + when: dst_image.images | length != 0 and dst_image.images[0]['Config']['Image'] != src_image.images[0]['Config']['Image'] + ansible.builtin.debug: + msg: "Images differ between {{ item.value.image_instance }} to {{ item.key }}. You may need to run:\n$ ansible-playbook docker_odoo_operations_playbook.yml -l '{{ inventory_hostname }}' -t 'restart_prod_on_test_image' -e 'instance={{ item.key }}'" - name: Copy image from image_instance if it does not exist - when: prod_image.images | length == 0 + when: dst_image.images | length == 0 community.docker.docker_image: name: "filament/{{ item.value.image_instance }}:{{ instance_odoo_setup.odoo_version }}" repository: "filament/{{ item.key }}:{{ instance_odoo_setup.odoo_version }}" -- GitLab