From db3814c5f82a99e2606b3d3504508f3aa7f98467 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20-=20Le=20Filament?= <theo@le-filament.com>
Date: Thu, 8 Jun 2023 16:54:56 +0200
Subject: [PATCH] fix(handler): update name and conditions

---
 handlers/main.yml  | 12 ++++++------
 tasks/instance.yml |  2 +-
 tasks/main.yml     |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/handlers/main.yml b/handlers/main.yml
index eb5e8ae..ffd6335 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -10,25 +10,25 @@
     name: lefilament/odoo:{{ instance_odoo_version }}_ml
     source: pull
     force_source: true
-  when: not ansible_check_mode and odoo_multilingual is defined and odoo_multilingual
+  when: not ansible_check_mode and instance.value.odoo_multilingual is defined and instance.value.odoo_multilingual
 
 - name: pull odoo Python3.6 image
   docker_image:
     name: lefilament/odoo:{{ instance_odoo_version }}_py3.6
     source: pull
     force_source: true
-  when: not ansible_check_mode and odoo_python36 is defined and odoo_python36
+  when: not ansible_check_mode and instance.value.odoo_python36 is defined and instance.value.odoo_python36
 
 - name: pull odoo image
   docker_image:
     name: lefilament/odoo:{{ instance_odoo_version }}
     source: pull
     force_source: true
-  when: not ansible_check_mode and (odoo_multilingual is not defined or not odoo_multilingual) and (odoo_python36 is not defined or not odoo_python36)
+  when: not ansible_check_mode and (instance.value.odoo_multilingual is not defined or not instance.value.odoo_multilingual) and (instance.value.odoo_python36 is not defined or not instance.value.odoo_python36)
 
 - name: build odoo image
   docker_compose:
-    project_src: /home/docker/{{ instance_name }}/
+    project_src: /home/docker/{{ instance.key }}/
     build: true
     nocache: true
     recreate: always
@@ -40,7 +40,7 @@
 
 - name: start odoo container
   docker_compose:
-    project_src: /home/docker/{{ instance_name }}/
+    project_src: /home/docker/{{ instance.key }}/
     remove_orphans: true
   when: not ansible_check_mode
 
@@ -54,6 +54,6 @@
 
 - name: remove ssh private keys
   file:
-    path: "/home/docker/{{ instance_name }}/odoo/id_ed25519.sources"
+    path: "/home/docker/{{ instance.key }}/odoo/id_ed25519.sources"
     state: absent
   when: not ansible_check_mode and inventory_hostname not in groups['maintenance_contract']
diff --git a/tasks/instance.yml b/tasks/instance.yml
index 8e5ca10..dea6262 100644
--- a/tasks/instance.yml
+++ b/tasks/instance.yml
@@ -246,7 +246,7 @@
 # Flush handlers.
 - name: set facts
   ansible.builtin.set_fact:
-    instance_name: "{{ item.key }}"
+    instance: "{{ {'key': item.key, 'value': item.value} }}"
     instance_odoo_version: "{{ instance_odoo_setup.odoo_version }}"
     cacheable: no
 
diff --git a/tasks/main.yml b/tasks/main.yml
index d64e4d0..ec42316 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -10,7 +10,7 @@
     owner: root
     group: root
     mode: '0400'
-  notify: start odoo docker whitelists
+  notify: start odoo whitelists
   when: restrict_internet_access and whitelisted_urls is defined
   tags: odoo_nonprod, odoo_prod
 
-- 
GitLab