From cc3d2b97e0b3d151762c151061b210c1ad8a8adc Mon Sep 17 00:00:00 2001 From: Arthur BOUDREAULT Date: Tue, 19 Jul 2022 14:47:08 +0000 Subject: [PATCH] refactor: update roles tags + drop cron tag docs: new borg tag --- README-FR.md | 7 ++++--- README.md | 7 ++++--- roles/ynh_apps/tasks/app.yml | 12 ++++-------- roles/ynh_apps/tasks/apps.yml | 9 +++------ roles/ynh_apps/tasks/main.yml | 4 +--- roles/ynh_backup/tasks/backup.yml | 10 +++------- roles/ynh_backup/tasks/borgbackup.yml | 24 ++++++++++++++++++++++++ roles/ynh_backup/tasks/main.yml | 7 +++---- roles/ynh_config/tasks/autoupdate.yml | 2 -- roles/ynh_setup/tasks/main.yml | 3 ++- 10 files changed, 48 insertions(+), 37 deletions(-) diff --git a/README-FR.md b/README-FR.md index 0ab0d65..ee52760 100644 --- a/README-FR.md +++ b/README-FR.md @@ -34,15 +34,16 @@ Ces tags sont applicables suivant les rôles. |tags|commentaires| |----|-------| +|pkg|Tâches d'installation de paquets.| +|linux|Tâches liées à l'OS Linux.| |yunohost|Tâches spécifiques à Yunohost lui-même (installation ou configuration).| |users|Tâches spécifiques aux utilisateurs de Yunohost.| |domains|Tâches spécifiques aux domaines liés à Yunohost.| |apps|Tâches spécifiques aux applications de Yunohost.| |update|Tâches liées aux paramètres de mise à jour de Yunohost.| |smtp|Tâches liées aux paramètres de relais smtp de Yunohost.| -|backup|Tâches liées aux sauvegardes de Yunohost.| -|pkg|Tâches d'installation de paquets.| -|linux|Tâches liées à l'OS Linux.| +|backup|Tâches liées aux sauvegardes de Yunohost en local.| +|borg|Tâches liées aux sauvegardes avec BorgBackup.| ## License diff --git a/README.md b/README.md index fc83c66..4b101a6 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,16 @@ These tags are applicable to roles. |tags|comment| |----|-------| +|pkg|Tasks that install packages.| +|linux|Tasks related to Linux.| |yunohost|Tasks specific to Yunohost itself (setup or configuration).| |users|Tasks specific to users in Yunohost.| |domains|Tasks specific to domains linked to Yunohost.| |apps|Tasks specific to Yunohost apps.| |update|Tasks related to Yunohost update settings.| |smtp|Tasks related to Yunohost smtp relay settings.| -|backup|Tasks related to Yunohost backups.| -|pkg|Tasks that install packages.| -|linux|Tasks related to Linux OS.| +|backup|Tasks related to local Yunohost backups.| +|borg|Tasks related to backups with BorgBackup.| ## License diff --git a/roles/ynh_apps/tasks/app.yml b/roles/ynh_apps/tasks/app.yml index cf7519b..a024560 100644 --- a/roles/ynh_apps/tasks/app.yml +++ b/roles/ynh_apps/tasks/app.yml @@ -24,8 +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: - - apps + tags: apps # Post-installation part - name: Create post-install template @@ -37,8 +36,7 @@ mode: "{{ (item.type == 'script') | ternary('740', '660') }}" loop: "{{ ynh_app.post_install|default([]) }}" when: ynh_app.post_install - tags: - - apps + tags: apps - name: Launch post-install script ansible.builtin.command: "{{ ynh_app_post_install.dest }}" @@ -48,8 +46,7 @@ loop_control: loop_var: ynh_app_post_install when: ynh_app_post_install.type == "script" - tags: - - apps + tags: apps - name: Remove script after execution ansible.builtin.file: @@ -59,5 +56,4 @@ loop_control: loop_var: ynh_app_post_install when: ynh_app_post_install.type == "script" - tags: - - apps + tags: apps diff --git a/roles/ynh_apps/tasks/apps.yml b/roles/ynh_apps/tasks/apps.yml index 9fb8e0e..240a6df 100644 --- a/roles/ynh_apps/tasks/apps.yml +++ b/roles/ynh_apps/tasks/apps.yml @@ -22,13 +22,11 @@ ansible.builtin.command: yunohost app map --output-as json register: ynh_installed_apps_raw changed_when: False - tags: - - apps + tags: apps - name: Format json of apps ansible.builtin.set_fact: ynh_installed_apps="{{ ynh_installed_apps_raw.stdout | from_json }}" - tags: - - apps + tags: apps - name: Install yunohost apps and perform post-install ansible.builtin.include_tasks: app.yml @@ -36,5 +34,4 @@ loop_control: loop_var: ynh_app when: ynh_app.label not in ynh_installed_apps.values() - tags: - - apps + tags: apps diff --git a/roles/ynh_apps/tasks/main.yml b/roles/ynh_apps/tasks/main.yml index 289486c..0b11815 100644 --- a/roles/ynh_apps/tasks/main.yml +++ b/roles/ynh_apps/tasks/main.yml @@ -21,6 +21,4 @@ - name: Install Yunohost apps ansible.builtin.include_tasks: apps.yml when: ynh_apps - tags: - - yunohost - - apps + tags: apps diff --git a/roles/ynh_backup/tasks/backup.yml b/roles/ynh_backup/tasks/backup.yml index c235c3c..688d36a 100644 --- a/roles/ynh_backup/tasks/backup.yml +++ b/roles/ynh_backup/tasks/backup.yml @@ -23,8 +23,7 @@ path: "{{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}" state: directory mode: '0750' - tags: - - backup + tags: backup - name: Create backup script ansible.builtin.template: @@ -33,8 +32,7 @@ owner: root group: root mode: '0740' - tags: - - backup + tags: backup - name: Create cron task to schedule YNH backup script ansible.builtin.cron: @@ -46,6 +44,4 @@ user: root job: "{{ ynh_backup_dest_script }}" cron_file: ynh_backup_cron - tags: - - backup - - cron + tags: backup diff --git a/roles/ynh_backup/tasks/borgbackup.yml b/roles/ynh_backup/tasks/borgbackup.yml index 3d87cda..cae7b3d 100644 --- a/roles/ynh_backup/tasks/borgbackup.yml +++ b/roles/ynh_backup/tasks/borgbackup.yml @@ -21,18 +21,30 @@ ansible.builtin.command: ansible-galaxy install m3nu.ansible_role_borgbackup,v0.9.0 -p ~/.ansible/roles delegate_to: localhost become: False + tags: + - backup + - borg - name: run BorgBackup role ansible.builtin.import_role: name: m3nu.ansible_role_borgbackup + tags: + - backup + - borg - name: Create backup folder for BorgBackup repository ansible.builtin.file: path: "{{ borg_repository }}" state: directory mode: '0750' + tags: + - backup + - borg - name: Configure host for Borg Remote repository + tags: + - backup + - borg block: - name: deploy ssh public key for BorgBackup ansible.builtin.copy: @@ -58,6 +70,9 @@ line: "{{ ynh_ssh_borg_command }}" state: present when: ynh_ssh_borg_command is defined + tags: + - backup + - borg - name: change archive name in "/etc/borgmatic/{{ borgmatic_config_name }}" @@ -66,6 +81,9 @@ regexp: "archive_name_format:" line: " archive_name_format: {{ borg_archive_name_format }}" state: present + tags: + - backup + - borg - name: Create borg launch script in /usr/local/bin ansible.builtin.copy: @@ -77,6 +95,12 @@ owner: root group: root mode: "0755" + tags: + - backup + - borg - name: Initialize a new Borg repository ansible.builtin.command: "{{ borg_init_command }}" + tags: + - backup + - borg diff --git a/roles/ynh_backup/tasks/main.yml b/roles/ynh_backup/tasks/main.yml index 86cbde3..ac16ba4 100644 --- a/roles/ynh_backup/tasks/main.yml +++ b/roles/ynh_backup/tasks/main.yml @@ -21,12 +21,11 @@ - name: Enable Yunohost apps backup ansible.builtin.include_tasks: backup.yml when: ynh_backup.scheduled - tags: - - backup + tags: backup - name: Use Borg Backup with YunoHost ansible.builtin.include_tasks: borgbackup.yml when: ynh_borg_backup_scheduled tags: - - backup - - borg + - backup + - borg diff --git a/roles/ynh_config/tasks/autoupdate.yml b/roles/ynh_config/tasks/autoupdate.yml index d840481..ddd0be4 100644 --- a/roles/ynh_config/tasks/autoupdate.yml +++ b/roles/ynh_config/tasks/autoupdate.yml @@ -28,7 +28,6 @@ tags: - yunohost - update - - cron - name: Creates cron task under /etc/cron.d to auto-update Yunohost ansible.builtin.cron: @@ -41,4 +40,3 @@ tags: - yunohost - update - - cron diff --git a/roles/ynh_setup/tasks/main.yml b/roles/ynh_setup/tasks/main.yml index 83faae0..93c9463 100644 --- a/roles/ynh_setup/tasks/main.yml +++ b/roles/ynh_setup/tasks/main.yml @@ -53,6 +53,7 @@ - "{{ ynh_data_dirs }}" tags: - linux + - yunohost when: ynh_data_dirs_enabled - name: Create symbolic links for Yunohost subdirs @@ -65,6 +66,7 @@ - "{{ ynh_data_dirs }}" tags: - linux + - yunohost when: ynh_data_dirs_enabled - name: Test if Yunohost is already installed @@ -97,7 +99,6 @@ when: not ynh_file_install.stat.exists tags: - yunohost - - domains - name: Create extra domains ansible.builtin.include_tasks: domains.yml