From 335cb75c49c979f9d2e4e8b9d13cc5ded0082828 Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <arthur@lydra.fr>
Date: Mon, 31 Jan 2022 12:02:00 +0100
Subject: [PATCH] refactor: restructuring role into collection #7

---
 plugins/README.md                 | 31 -------------------------------
 roles/ynh_backup/README.md        |  8 +-------
 roles/ynh_backup/tasks/backup.yml |  6 +++---
 roles/ynh_backup/tasks/main.yml   |  2 +-
 roles/ynh_config/README-FR.md     |  8 +-------
 roles/ynh_config/README.md        | 10 ++--------
 roles/ynh_config/tasks/main.yml   |  2 +-
 roles/ynh_setup/tasks/app.yml     |  8 ++++----
 roles/ynh_setup/tasks/apps.yml    |  6 +++---
 roles/ynh_setup/tasks/domains.yml |  6 +++---
 roles/ynh_setup/tasks/main.yml    | 20 ++++++++++----------
 roles/ynh_setup/tasks/users.yml   |  6 +++---
 12 files changed, 32 insertions(+), 81 deletions(-)
 delete mode 100644 plugins/README.md

diff --git a/plugins/README.md b/plugins/README.md
deleted file mode 100644
index 448a4ba..0000000
--- a/plugins/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# Collections Plugins Directory
-
-This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that
-is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that
-would contain module utils and modules respectively.
-
-Here is an example directory of the majority of plugins currently supported by Ansible:
-
-```
-└── plugins
-    ├── action
-    ├── become
-    ├── cache
-    ├── callback
-    ├── cliconf
-    ├── connection
-    ├── filter
-    ├── httpapi
-    ├── inventory
-    ├── lookup
-    ├── module_utils
-    ├── modules
-    ├── netconf
-    ├── shell
-    ├── strategy
-    ├── terminal
-    ├── test
-    └── vars
-```
-
-A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.10/plugins/plugins.html).
diff --git a/roles/ynh_backup/README.md b/roles/ynh_backup/README.md
index 8382415..4d830ca 100644
--- a/roles/ynh_backup/README.md
+++ b/roles/ynh_backup/README.md
@@ -56,17 +56,11 @@ None.
 
 ```yml
 ---
-- name: Install Yunohost on Debian Server
+- name: Configure Yunohost backups
   hosts: all
   become: True
   collections:
     - lydra.yunohost
-  pre_tasks:
-    - name: Update all packages and index
-      ansible.builtin.apt:
-        upgrade: dist
-        update_cache: yes
-    
   roles:
     - ynh_backup
 ```
diff --git a/roles/ynh_backup/tasks/backup.yml b/roles/ynh_backup/tasks/backup.yml
index b6f4926..f2d83ff 100644
--- a/roles/ynh_backup/tasks/backup.yml
+++ b/roles/ynh_backup/tasks/backup.yml
@@ -23,7 +23,7 @@
     path: "{{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
     state: directory
     mode: '0750'
-  tags: 
+  tags:
     - "backup"
 
 - name: Create backup script
@@ -33,7 +33,7 @@
     owner: root
     group: root
     mode: '0740'
-  tags: 
+  tags:
     - "backup"
     - "cron"
 
@@ -47,6 +47,6 @@
     user: root
     job: "{{ ynh_backup.dest_script | default('/usr/local/bin/') }}ynh_backup.sh"
     cron_file: ynh_backup_cron
-  tags: 
+  tags:
     - "backup"
     - "cron"
diff --git a/roles/ynh_backup/tasks/main.yml b/roles/ynh_backup/tasks/main.yml
index 73baaf3..328ff06 100644
--- a/roles/ynh_backup/tasks/main.yml
+++ b/roles/ynh_backup/tasks/main.yml
@@ -21,5 +21,5 @@
 - name: Enable Yunohost apps backup
   ansible.builtin.include_tasks: backup.yml
   when: ynh_backup.scheduled
-  tags: 
+  tags:
     - "backup"
diff --git a/roles/ynh_config/README-FR.md b/roles/ynh_config/README-FR.md
index 882a71a..ffc3fd4 100644
--- a/roles/ynh_config/README-FR.md
+++ b/roles/ynh_config/README-FR.md
@@ -68,17 +68,11 @@ Aucune.
 
 ```yml
 ---
-- name: Install Yunohost on Debian Server
+- name: Configure Yunohost on Debian Server
   hosts: all
   become: True
   collections:
     - lydra.yunohost
-  pre_tasks:
-    - name: Update all packages and index
-      ansible.builtin.apt:
-        upgrade: dist
-        update_cache: yes
-    
   roles:
     - ynh_config
 ```
diff --git a/roles/ynh_config/README.md b/roles/ynh_config/README.md
index b704c6e..d930149 100644
--- a/roles/ynh_config/README.md
+++ b/roles/ynh_config/README.md
@@ -56,7 +56,7 @@ A cron job can been set up to automate the check for system and application upda
 - `ynh_autoupdate.system`: is mandatory. Enables automatic updating of the Yunohost system by setting the value to `True`.
 - `ynh_autoupdate.dest_script`: it is the path to the directory where the update script will be installed on the server. The default value is `/usr/local/bin`. The script is named `ynh_autoupdate.sh`.
 
-If available, updates are done automatically. In case of problems following an application update, you can read logs located in `/var/log/yunohost/categories/operation` . You also have the possibility to rollback to the previous version since Yunohost always makes an automatic backup of an application when it is updated. 
+If available, updates are done automatically. In case of problems following an application update, you can read logs located in `/var/log/yunohost/categories/operation` . You also have the possibility to rollback to the previous version since Yunohost always makes an automatic backup of an application when it is updated.
 
 To learn more about how updates work in Yunohost you can go [here](https://yunohost.org/fr/update). The changelog of Yunohost versions is also available [here](https://forum.yunohost.org/tag/ynh_release).
 
@@ -68,17 +68,11 @@ None.
 
 ```yml
 ---
-- name: Install Yunohost on Debian Server
+- name: Configure Yunohost on Debian Server
   hosts: all
   become: True
   collections:
     - lydra.yunohost
-  pre_tasks:
-    - name: Update all packages and index
-      ansible.builtin.apt:
-        upgrade: dist
-        update_cache: yes
-    
   roles:
     - ynh_config
 ```
diff --git a/roles/ynh_config/tasks/main.yml b/roles/ynh_config/tasks/main.yml
index fbcd358..9acd0f0 100644
--- a/roles/ynh_config/tasks/main.yml
+++ b/roles/ynh_config/tasks/main.yml
@@ -28,5 +28,5 @@
 - name: Configures Yunohost autoupdate
   ansible.builtin.include_tasks: autoupdate.yml
   when: ynh_autoupdate.scheduled
-  tags: 
+  tags:
     - "update"
diff --git a/roles/ynh_setup/tasks/app.yml b/roles/ynh_setup/tasks/app.yml
index d039599..f7c824c 100644
--- a/roles/ynh_setup/tasks/app.yml
+++ b/roles/ynh_setup/tasks/app.yml
@@ -24,7 +24,7 @@
      --label "{{ ynh_app.label }}" \
      --args "{% for key, value in ynh_app.args.items() %}{{ key }}={{ value }}{% if not loop.last %}&{% endif %}{% endfor %}"
   changed_when: False
-  tags: 
+  tags:
     - "yunohost"
     - "apps"
 
@@ -38,7 +38,7 @@
     mode: "{{ (item.type == 'script') | ternary('740', '660') }}"
   loop: "{{ ynh_app.post_install|default([]) }}"
   when: ynh_app.post_install
-  tags: 
+  tags:
     - "apps"
 
 - name: Launch post-install script
@@ -49,7 +49,7 @@
   loop_control:
     loop_var: ynh_app_post_install
   when: ynh_app_post_install.type == "script"
-  tags: 
+  tags:
     - "apps"
 
 - name: Remove script after execution
@@ -60,5 +60,5 @@
   loop_control:
     loop_var: ynh_app_post_install
   when: ynh_app_post_install.type == "script"
-  tags: 
+  tags:
     - "apps"
diff --git a/roles/ynh_setup/tasks/apps.yml b/roles/ynh_setup/tasks/apps.yml
index 9289ddd..ebc3a84 100644
--- a/roles/ynh_setup/tasks/apps.yml
+++ b/roles/ynh_setup/tasks/apps.yml
@@ -22,13 +22,13 @@
   ansible.builtin.command: yunohost app map --output-as json
   register: ynh_installed_apps_raw
   changed_when: False
-  tags: 
+  tags:
     - "yunohost"
     - "apps"
 
 - name: Format json of apps
   ansible.builtin.set_fact: ynh_installed_apps="{{ ynh_installed_apps_raw.stdout | from_json }}"
-  tags: 
+  tags:
     - "yunohost"
     - "apps"
 
@@ -38,7 +38,7 @@
   loop_control:
     loop_var: ynh_app
   when: ynh_app.label not in ynh_installed_apps.values()
-  tags: 
+  tags:
     - "yunohost"
     - "apps"
 
diff --git a/roles/ynh_setup/tasks/domains.yml b/roles/ynh_setup/tasks/domains.yml
index baa41af..d018858 100644
--- a/roles/ynh_setup/tasks/domains.yml
+++ b/roles/ynh_setup/tasks/domains.yml
@@ -22,13 +22,13 @@
   ansible.builtin.command: yunohost domain list --output-as json
   register: ynh_installed_domains_raw
   changed_when: False
-  tags: 
+  tags:
     - "yunohost"
     - "domains"
 
 - name: Format json of domains
   ansible.builtin.set_fact: ynh_installed_domains="{{ ynh_installed_domains_raw.stdout | from_json }}"
-  tags: 
+  tags:
     - "yunohost"
     - "domains"
 
@@ -36,6 +36,6 @@
   ansible.builtin.command: yunohost domain add {{ item }}
   with_items: "{{ ynh_extra_domains }}"
   when: item not in ynh_installed_domains.domains
-  tags: 
+  tags:
     - "yunohost"
     - "domains"
diff --git a/roles/ynh_setup/tasks/main.yml b/roles/ynh_setup/tasks/main.yml
index 2736af9..3041ee7 100644
--- a/roles/ynh_setup/tasks/main.yml
+++ b/roles/ynh_setup/tasks/main.yml
@@ -24,13 +24,13 @@
       - git
       - dialog
     state: present
-  tags: 
+  tags:
     - "pkg"
 
 - name: Test if Yunohost is already installed
   ansible.builtin.stat: path=/etc/yunohost/installed
   register: ynh_file_install
-  tags: 
+  tags:
     - "yunohost"
 
 - name: Download Yunohost install script
@@ -39,13 +39,13 @@
     dest: /tmp/install_yunohost.sh
     mode: 700
   when: not ynh_file_install.stat.exists
-  tags: 
+  tags:
     - "yunohost"
 
 - name: Launch Yunohost install script
   ansible.builtin.command: /tmp/install_yunohost.sh -a
   when: not ynh_file_install.stat.exists
-  tags: 
+  tags:
     - "yunohost"
 
 - name: Launch Yunohost postinstall
@@ -55,39 +55,39 @@
       --password "{{ ynh_admin_password }}" \
       {% if ynh_ignore_dyndns_server %} --ignore-dyndns {% endif %}
   when: not ynh_file_install.stat.exists
-  tags: 
+  tags:
     - "yunohost"
     - "domains"
 
 - name: Create extra domains
   ansible.builtin.include_tasks: domains.yml
   when: ynh_extra_domains
-  tags: 
+  tags:
     - "yunohost"
     - "domains"
 
 - name: Run first Yunohost diagnosis
   ansible.builtin.command: yunohost diagnosis run
   when: not ynh_file_install.stat.exists
-  tags: 
+  tags:
     - "yunohost"
 
 - name: Install domain certificates
   ansible.builtin.command: yunohost domain cert-install
   changed_when: False
-  tags: 
+  tags:
     - "yunohost"
 
 - name: Add Yunohost users
   ansible.builtin.include_tasks: users.yml
   when: ynh_users
-  tags: 
+  tags:
     - "yunohost"
     - "users"
 
 - name: Install Yunohost apps
   ansible.builtin.include_tasks: apps.yml
   when: ynh_apps
-  tags: 
+  tags:
     - "yunohost"
     - "apps"
diff --git a/roles/ynh_setup/tasks/users.yml b/roles/ynh_setup/tasks/users.yml
index d4ad86a..5a93dc2 100644
--- a/roles/ynh_setup/tasks/users.yml
+++ b/roles/ynh_setup/tasks/users.yml
@@ -22,13 +22,13 @@
   ansible.builtin.command: yunohost user list --output-as json
   register: ynh_registered_users_raw
   changed_when: False
-  tags: 
+  tags:
     - "yunohost"
     - "users"
 
 - name: Format json of users
   ansible.builtin.set_fact: ynh_registered_users="{{ ynh_registered_users_raw.stdout | from_json }}"
-  tags: 
+  tags:
     - "yunohost"
     - "users"
 
@@ -41,6 +41,6 @@
     -p "{{ item.pass }}"
   loop: "{{ ynh_users }}"
   when: item.name not in ynh_registered_users.users.keys()
-  tags: 
+  tags:
     - "yunohost"
     - "users"
-- 
GitLab