From b4c86d08fe51c3940098ce086077839c88a6585a Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <arthur@lydra.fr>
Date: Tue, 14 Mar 2023 14:28:28 +0100
Subject: [PATCH] refactor: add Christophe suggestions

---
 roles/ynh_config/README-FR.md      | 3 +--
 roles/ynh_config/README.md         | 3 +--
 roles/ynh_config/defaults/main.yml | 1 -
 roles/ynh_config/tasks/main.yml    | 6 +++---
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/roles/ynh_config/README-FR.md b/roles/ynh_config/README-FR.md
index 1fee277..cbdd402 100644
--- a/roles/ynh_config/README-FR.md
+++ b/roles/ynh_config/README-FR.md
@@ -15,7 +15,6 @@ Les variables par défaut sont disponibles dans `default/main.yml` cependant il
 ### Configuration d'un relais SMTP
 
 ```yml
-ynh_smtp_relay_enabled: "yes"
 ynh_smtp_relay:
     host: smtp.domain.tld
     port: 25
@@ -24,7 +23,7 @@ ynh_smtp_relay:
 ```
 
 Yunohost possède son propre serveur SMTP natif mais il est aussi possible de configurer Yunohost pour qu'il utilise un relais SMTP à la place.
-Pour faire cela, mettez la variable `ynh_smtp_relay_enabled` à `yes` et créez la variable `ynh_smtp_relay` pour y mettre vos propres valeurs. Vous pouvez en apprendre plus sur les relais SMTP [ici](https://yunohost.org/fr/administrate/specific_use_cases/email_relay).
+Pour faire cela, créez la variable `ynh_smtp_relay` pour y mettre vos propres valeurs. Vous pouvez en apprendre plus sur les relais SMTP [ici](https://yunohost.org/fr/administrate/specific_use_cases/email_relay).
 
 ### Configuration des mises à jour
 
diff --git a/roles/ynh_config/README.md b/roles/ynh_config/README.md
index 96cb947..82c73ed 100644
--- a/roles/ynh_config/README.md
+++ b/roles/ynh_config/README.md
@@ -15,7 +15,6 @@ Default variables are available in `default/main.yml` however it is necessary to
 ### SMTP relay configuration
 
 ```yml
-ynh_smtp_relay_enabled: "yes"
 ynh_smtp_relay:
     host: smtp.domain.tld
     port: 25
@@ -24,7 +23,7 @@ ynh_smtp_relay:
 ```
 
 There is a built-in SMTP server on Yunohost but you can also set up Yunohost to use a SMTP relay instead.
-In order to do so, set the `ynh_smtp_relay_enabled` variable to `yes` and create the `ynh_smtp_relay` variable in order to provide your own values. You can learn more about SMTP relay [here](https://yunohost.org/en/administrate/specific_use_cases/email_relay).
+In order to do so, create the `ynh_smtp_relay` variable in order to provide your own values. You can learn more about SMTP relay [here](https://yunohost.org/en/administrate/specific_use_cases/email_relay).
 
 ### Updates configuration
 
diff --git a/roles/ynh_config/defaults/main.yml b/roles/ynh_config/defaults/main.yml
index 0c2bd1d..1359ca3 100644
--- a/roles/ynh_config/defaults/main.yml
+++ b/roles/ynh_config/defaults/main.yml
@@ -25,7 +25,6 @@ ynh_smtp_relay:
 
 # SMTP custom settings (Only override if you need a SMTP relay)
 # Example:
-ynh_smtp_relay_enabled: no
 # ynh_smtp_relay:
     # host: smtp.domain.tld
     # port: "25"
diff --git a/roles/ynh_config/tasks/main.yml b/roles/ynh_config/tasks/main.yml
index 4ebb42d..bbb1bad 100644
--- a/roles/ynh_config/tasks/main.yml
+++ b/roles/ynh_config/tasks/main.yml
@@ -18,10 +18,10 @@
 #                                                                             #
 #-----------------------------------------------------------------------------#
 
-- name: Enable SMTP relay configuration
+- name: Ensure SMTP relay is enabled
   ansible.builtin.command:
-    "yunohost settings set email.smtp.smtp_relay_enabled -v {{ ynh_smtp_relay_enabled | default('no') }}"
-  when: ynh_smtp_relay_enabled
+    "yunohost settings set email.smtp.smtp_relay_enabled -v yes"
+  when: ynh_smtp_relay
   tags:
     - yunohost
     - smtp
-- 
GitLab