From 2ec9d974a0ee2339a162accef393fa1d81fa4fd0 Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <arthur@lydra.fr>
Date: Tue, 26 Jul 2022 11:00:53 +0200
Subject: [PATCH] refactor: add default vars

---
 roles/ynh_backup/tasks/backup.yml           | 2 +-
 roles/ynh_backup/templates/ynh_backup.sh.j2 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/roles/ynh_backup/tasks/backup.yml b/roles/ynh_backup/tasks/backup.yml
index 91d2782..0451b01 100644
--- a/roles/ynh_backup/tasks/backup.yml
+++ b/roles/ynh_backup/tasks/backup.yml
@@ -20,7 +20,7 @@
 - name: Fail if variables are not used correctly
   ansible.builtin.fail:
     msg: You need to define variable ynh_backup.apps and / or ynh_backup.system to True
-  when: ynh_backup.apps | default(False) is false and ynh_backup.system | default(False) is false
+  when: ynh_backup.apps | default(True) is false and ynh_backup.system | default(True) is false
   tags: backup
 
 - name: Create backup folder if doesn't already exist
diff --git a/roles/ynh_backup/templates/ynh_backup.sh.j2 b/roles/ynh_backup/templates/ynh_backup.sh.j2
index 4df454f..3965bc1 100644
--- a/roles/ynh_backup/templates/ynh_backup.sh.j2
+++ b/roles/ynh_backup/templates/ynh_backup.sh.j2
@@ -13,7 +13,7 @@ _fail() {
 
 _create_ynh_backup() {
   echo "Backing up $today YunoHost data now."
-  yunohost backup create {% if ynh_backup.system|default(ynh_backup.system == true) %}--system{% endif %}{% if ynh_backup.apps|default(ynh_backup.apps == true) %} --apps{% endif %}{% if ynh_backup.directory|default(ynh_backup.directory == "/data/backup") %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup"
+  yunohost backup create {% if ynh_backup.system | default(True) %}--system{% endif %}{% if ynh_backup.apps | default(True) %} --apps{% endif %}{% if ynh_backup.directory | default("/data/backup") %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup"
 
 }
 
-- 
GitLab