From df59eb85c2965acaaed64cb86d0e6df53b403948 Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <arthur@lydra.fr>
Date: Thu, 27 Jan 2022 14:15:28 +0100
Subject: [PATCH] refactor: restructuring role into collection #3

---
 README-FR.md                   | 34 ++++++++++++++++++++++++++++++++++
 README.md                      | 21 ++++++++++++++++++---
 galaxy.yml                     |  6 +++---
 roles/ynh_setup/README-FR.md   |  8 ++++++--
 roles/ynh_setup/README.md      |  6 ++++--
 roles/ynh_setup/tasks/main.yml |  9 ---------
 6 files changed, 65 insertions(+), 19 deletions(-)
 create mode 100644 README-FR.md

diff --git a/README-FR.md b/README-FR.md
new file mode 100644
index 0000000..04d7e13
--- /dev/null
+++ b/README-FR.md
@@ -0,0 +1,34 @@
+[![](https://img.shields.io/liberapay/receives/cchaudier.svg?logo=liberapay)](https://liberapay.com/cchaudier/donate)
+[![](https://lab.frogg.it/lydra/yunohost/ansible-yunohost/badges/main/pipeline.svg)](https://lab.frogg.it/lydra/yunohost/ansible-yunohost/-/pipelines)
+[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
+[![Ansible Role](https://img.shields.io/ansible/role/56544)](https://galaxy.ansible.com/lydra/yunohost)
+[![Ansible Quality Score](https://img.shields.io/ansible/quality/56544)](https://galaxy.ansible.com/lydra/yunohost)
+[![Ansible Role](https://img.shields.io/ansible/role/d/56544)](https://galaxy.ansible.com/lydra/yunohost)
+[![GitHub last commit](https://img.shields.io/github/last-commit/LydraFr/ansible-yunohost)](https://github.com/LydraFr/ansible-yunohost)
+[![GitHub Release Date](https://img.shields.io/github/release-date/LydraFr/ansible-yunohost)](https://github.com/LydraFr/ansible-yunohost)
+[![GitHub Repo stars](https://img.shields.io/github/stars/LydraFr/ansible-yunohost?style=social)](https://github.com/LydraFr/ansible-yunohost)
+
+# Collection Ansible - lydra.yunohost
+
+[🇬🇧 English version](README.md)
+
+Cette collection vise à installer, configurer et sauvegarder [Yunohost](https://yunohost.org/#/).
+Comme il s'agit d'une collection indépendante, elle peut être publiée selon sa propre cadence de publication.
+
+## Prérequis
+
+Votre serveur doit être basé sur du Debian Buster.
+
+## Contenu de la collection
+
+### Rôles
+
+- `lydra.yunohost.ynh_setup` : Ce rôle prépare les serveurs à base de Debian-Buster à exécuter Yunohost.
+- `lydra.yunohost.ynh_config` : Ce rôle gère la configuration et le démarrage des différents services de Yunohost (relais SMTP, mises à jour automatiques).
+- `lydra.yunohost.ynh_backup` : Ce rôle gère la configuration des sauvegardes.
+
+## License
+
+[![ansible-yunohost Copyright 2021 Lydra](https://www.gnu.org/graphics/gplv3-with-text-136x68.png)](https://choosealicense.com/licenses/gpl-3.0/)
+
+**ansible-yunohost** est maintenu par [Lydra](https://lydra.fr/) et publié sous la licence GPL3.
diff --git a/README.md b/README.md
index cfa2976..fc3a7da 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,32 @@
+[![](https://img.shields.io/liberapay/receives/cchaudier.svg?logo=liberapay)](https://liberapay.com/cchaudier/donate)
+[![](https://lab.frogg.it/lydra/yunohost/ansible-yunohost/badges/main/pipeline.svg)](https://lab.frogg.it/lydra/yunohost/ansible-yunohost/-/pipelines)
+[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
+[![Ansible Role](https://img.shields.io/ansible/role/56544)](https://galaxy.ansible.com/lydra/yunohost)
+[![Ansible Quality Score](https://img.shields.io/ansible/quality/56544)](https://galaxy.ansible.com/lydra/yunohost)
+[![Ansible Role](https://img.shields.io/ansible/role/d/56544)](https://galaxy.ansible.com/lydra/yunohost)
+[![GitHub last commit](https://img.shields.io/github/last-commit/LydraFr/ansible-yunohost)](https://github.com/LydraFr/ansible-yunohost)
+[![GitHub Release Date](https://img.shields.io/github/release-date/LydraFr/ansible-yunohost)](https://github.com/LydraFr/ansible-yunohost)
+[![GitHub Repo stars](https://img.shields.io/github/stars/LydraFr/ansible-yunohost?style=social)](https://github.com/LydraFr/ansible-yunohost)
+
 # Ansible Collection - lydra.yunohost
 
-This collection aims at installing, configuring and backing up Yunohost.
+[🇫🇷 French version](README-FR.md)
+
+This collection aims at installing, configuring and backing up [Yunohost](https://yunohost.org/#/).
 As this is an independent collection, it can be released on its own release cadence.
 
+# Prerequisites
+
+Your server must be Debian-Buster based.
+
 ## Collection contents
 
 ### Roles
 
 - `lydra.yunohost.ynh_setup` : This role prepares servers with Debian-Buster-based to run Yunohost.
-- `lydra.yunohost.ynh_config` : This role manages configuring and starting various Yunohost services.
+- `lydra.yunohost.ynh_config` : This role manages configuring and starting various Yunohost services (SMTP relay, auto updates).
 - `lydra.yunohost.ynh_backup` : This role manages configuring of backups.
 
-
 ## License
 
 [![ansible-yunohost Copyright 2021 Lydra](https://www.gnu.org/graphics/gplv3-with-text-136x68.png)](https://choosealicense.com/licenses/gpl-3.0/)
diff --git a/galaxy.yml b/galaxy.yml
index 3cc030a..bfb0602 100644
--- a/galaxy.yml
+++ b/galaxy.yml
@@ -46,13 +46,13 @@ tags:
 dependencies: {}
 
 # The URL of the originating SCM repository
-repository: http://example.com/repository
+repository: https://github.com/LydraFr/ansible-yunohost
 
 # The URL to any online docs
-documentation: http://docs.example.com
+documentation: https://github.com/LydraFr/ansible-yunohost/blob/main/README.md
 
 # The URL to the homepage of the collection/project
-homepage: http://example.com
+homepage: https://github.com/LydraFr/ansible-yunohost
 
 # The URL to the collection issue tracker
 issues: http://example.com/issue/tracker
diff --git a/roles/ynh_setup/README-FR.md b/roles/ynh_setup/README-FR.md
index c94e273..bbacd32 100644
--- a/roles/ynh_setup/README-FR.md
+++ b/roles/ynh_setup/README-FR.md
@@ -99,6 +99,7 @@ ynh_apps:
 - `link` correspond au nom de l'application Yunohost qu'on veut installer.
 
 #### Concernant les arguments
+
 - `domain` est obligatoire. Il faut choisir un des domaines de son instance Yunohost.
 - `path` est obligatoire. Il faut choisir une URL pour accéder à son application comme `domain.tld/my_app`. Utilisez juste `/` si l'application doit s'installer sur un sous-domaine.
 - `is_public` est  un argument qu'on retrouve souvent. Paramétré sur `yes`, l'application sera accessible à tout le monde, même sans authentification sur le portail SSO Yunohost. Paramétré sur `no`, l'application ne sera accessible qu'après authentification.
@@ -106,7 +107,8 @@ ynh_apps:
 Pour les autres arguments, il faut se référer au `manifest.json` disponible dans le dépôt de l'application Yunohost qu'on installe. Vous pouvez en apprendre plus sur cette partie [ici](https://yunohost.org/fr/packaging_apps_manifest).
 
 #### Concernant la post-installation
-Il est possible de compléter l'installation des applications par l'ajout de templates jinja de configuration ou de scripts que vous aurez écrit de votre côté. 
+
+Il est possible de compléter l'installation des applications par l'ajout de templates jinja de configuration ou de scripts que vous aurez écrit de votre côté.
 Pour activer cette fonctionnalité, définissez la variable `post_install` qui correspond à la liste des fichiers de post-installation de votre application.
 Cette tâche utilisant le module template, vous pouvez tout à fait utiliser vos propres variables et les appeler dans vos fichiers de template. Pour en savoir sur ce module, cliquez [ici](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html).
 
@@ -129,6 +131,8 @@ Aucune.
 - name: Install Yunohost on Debian Server
   hosts: all
   become: True
+  collections:
+    - lydra.yunohost
   pre_tasks:
     - name: Update all packages and index
       ansible.builtin.apt:
@@ -136,7 +140,7 @@ Aucune.
         update_cache: yes
     
   roles:
-    - lydra.yunohost
+    - ynh_setup
 ```
 
 ## License
diff --git a/roles/ynh_setup/README.md b/roles/ynh_setup/README.md
index c7e9ded..084e91d 100644
--- a/roles/ynh_setup/README.md
+++ b/roles/ynh_setup/README.md
@@ -104,7 +104,7 @@ ynh_apps:
 - `path` is required. You have to choose a URL to access your application like `domain.tld/my_app`. Just use `/` if the application is to be installed on a subdomain.
 - `is_public` argument is a common one. Set to `yes`, the application will be accessible to everyone, even without authentication to the Yunohost SSO portal. Set to `no`, the application will be accessible only after authentication.
 
-For the other arguments, you have to refer to the `manifest.json` available in the repository of the Yunohost application you install. You can learn more about this part [here](https://yunohost.org/fr/packaging_apps_manifest). 
+For the other arguments, you have to refer to the `manifest.json` available in the repository of the Yunohost application you install. You can learn more about this part [here](https://yunohost.org/fr/packaging_apps_manifest).
 
 #### About the post-installation
 
@@ -131,6 +131,8 @@ None.
 - name: Install Yunohost on Debian Server
   hosts: all
   become: True
+  collections:
+    - lydra.yunohost
   pre_tasks:
     - name: Update all packages and index
       ansible.builtin.apt:
@@ -138,7 +140,7 @@ None.
         update_cache: yes
     
   roles:
-    - ansible-yunohost
+    - ynh_setup
 ```
 
 ## License
diff --git a/roles/ynh_setup/tasks/main.yml b/roles/ynh_setup/tasks/main.yml
index c8857d7..e0f8b73 100644
--- a/roles/ynh_setup/tasks/main.yml
+++ b/roles/ynh_setup/tasks/main.yml
@@ -60,11 +60,6 @@
   ansible.builtin.command: yunohost domain cert-install
   changed_when: False
 
-- name: Configure SMTP relay
-  ansible.builtin.include_tasks: smtp_relay.yml
-  loop: "{{ ynh_smtp_relay | dict2items }}"
-  when: item.value
-
 - name: Add Yunohost users
   ansible.builtin.include_tasks: users.yml
   when: ynh_users
@@ -72,7 +67,3 @@
 - name: Install Yunohost apps
   ansible.builtin.include_tasks: apps.yml
   when: ynh_apps
-
-- name: Configures Yunohost autoupdate
-  ansible.builtin.include_tasks: autoupdate.yml
-  when: ynh_autoupdate.scheduled
-- 
GitLab