---
- name: Vérification de la présence des paramètres d'entrées dans les variables
  ansible.builtin.fail:
    msg: |
      la variable {{ item }} est obligatoire pour
      utiliser le role set-logo.
      Veuillez la rajouter dans les host_vars
  when:
    - item is not defined
  loop:
    - zimbraSkinLogoURL
    - zimbraSkinLogoAppBanner
    - zimbraSkinLogoLoginBanner

## zimbraSkinLogoURL
- name: Récup param - zmprov gacf zimbraSkinLogoURL
  ansible.builtin.shell: |
    set -e -o pipefail
    /opt/zimbra/bin/zmprov gacf zimbraSkinLogoURL | awk '{print $2}'
  register: gcf
  changed_when: false
  args:
    executable: /bin/bash

- name: Set param - zmprov mcf zimbraSkinLogoURL
  ansible.builtin.command: "/opt/zimbra/bin/zmprov mcf zimbraSkinLogoURL {{ zimbraSkinLogoURL }}"
  when: gcf.stdout != zimbraSkinLogoURL
  notify:
    - Restart Mailbox

## zimbraSkinLogoAppBanner
- name: Get param - zmprov gacf zimbraSkinLogoAppBanner
  ansible.builtin.shell: |
    set -e -o pipefail
    /opt/zimbra/bin/zmprov gacf zimbraSkinLogoAppBanner | awk '{print $2}'
  register: gcf
  changed_when: false
  args:
    executable: /bin/bash

- name: Set param - zmprov mcf zimbraSkinLogoAppBanner
  ansible.builtin.command: "/opt/zimbra/bin/zmprov mcf zimbraSkinLogoAppBanner {{ zimbraSkinLogoAppBanner }}"
  when: gcf.stdout != zimbraSkinLogoAppBanner
  notify:
    - Restart Mailbox

## zimbraSkinLogoLoginBanner
- name: Get param - zmprov gacf zimbraSkinLogoLoginBanner
  ansible.builtin.shell: |
    set -e -o pipefail
    /opt/zimbra/bin/zmprov gacf zimbraSkinLogoLoginBanner | awk '{print $2}'
  register: gcf
  changed_when: false
  args:
    executable: /bin/bash

- name: Set param - zmprov mcf zimbraSkinLogoLoginBanner
  ansible.builtin.command: "/opt/zimbra/bin/zmprov mcf zimbraSkinLogoLoginBanner {{ zimbraSkinLogoLoginBanner }}"
  when: gcf.stdout != zimbraSkinLogoLoginBanner
  notify:
    - Restart Mailbox
