From 0f79911f3dfbad4bbf013662267bd08fa12b7cd5 Mon Sep 17 00:00:00 2001 From: Arthur BOUDREAULT Date: Thu, 3 Feb 2022 13:41:56 +0100 Subject: [PATCH] feat: adds symlink management --- README-FR.md | 1 + README.md | 1 + roles/ynh_setup/README-FR.md | 13 +++++++++++ roles/ynh_setup/README.md | 13 +++++++++++ roles/ynh_setup/defaults/main.yml | 9 ++++++++ roles/ynh_setup/tasks/main.yml | 36 +++++++++++-------------------- 6 files changed, 49 insertions(+), 24 deletions(-) diff --git a/README-FR.md b/README-FR.md index 5876a48..1ad3f34 100644 --- a/README-FR.md +++ b/README-FR.md @@ -45,6 +45,7 @@ Ces tags sont applicables suivant les rôles. |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.| ## License diff --git a/README.md b/README.md index 1690d7d..239c7bc 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ These tags are applicable to roles. |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.| ## License diff --git a/roles/ynh_setup/README-FR.md b/roles/ynh_setup/README-FR.md index 195760d..1d3687e 100644 --- a/roles/ynh_setup/README-FR.md +++ b/roles/ynh_setup/README-FR.md @@ -19,11 +19,24 @@ Les variables par défaut sont disponibles dans `default/main.yml` cependant il ynh_install_script_url: https://install.yunohost.org ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS + +ynh_dir: "/data/yunohost" + +ynh_data_dirs: + - path: "{{ ynh_dir }}/etc" + link: "/etc/yunohost" + - path: "{{ ynh_dir }}/var" + link: "/var/www" +ynh_data_dirs.enabled: True ``` - `ynh_install_script_url` est le script d'installation des packages Yunohost, par défaut c'est le script officiel. Yunohost ne s'installe que sur Debian 10. - `ynh_admin_password` est le mot de passe permettant d'accéder à l’interface d’administration du serveur. +- `ynh_data_dirs.enabled`: active les liens symboliques et permet de déplacer les répertoires de configurations et de données de YunoHost où vous le desirez. Mettez la valeur à `True`. +- `ynh_data_dirs.path`: il s'agit des répertoires où stocker les données de configuration de Yunohost ainsi que les applications. +- `ynh_data_dirs.link`: il s'agit des répertoire où seront fait les liens symboliques. + ### Gestion des domaines ```yml diff --git a/roles/ynh_setup/README.md b/roles/ynh_setup/README.md index 4e816a9..5b6afb2 100644 --- a/roles/ynh_setup/README.md +++ b/roles/ynh_setup/README.md @@ -19,11 +19,24 @@ Default variables are available in `default/main.yml` however it is necessary to ynh_install_script_url: https://install.yunohost.org ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS + +ynh_dir: "/data/yunohost" + +ynh_data_dirs: + - path: "{{ ynh_dir }}/etc" + link: "/etc/yunohost" + - path: "{{ ynh_dir }}/var" + link: "/var/www" +ynh_data_dirs.enabled: True ``` - `ynh_install_script_url` downloads official Yunohost script for installing Yunohost packages. Yunohost is only available on Debian 10. - `ynh_admin_password` is the password used to access to the server's administration interface. +- `ynh_data_dirs.enabled`: Enables symbolic links and allows you to move YunoHost's configuration and data directories wherever you want. Set the value to `True`. +- `ynh_data_dirs.path`: these are the directories where Yunohost configuration data and applications are stored. +- `ynh_data_dirs.link`: this is the directory where symbolic links will be made. + ### Domain management ```yml diff --git a/roles/ynh_setup/defaults/main.yml b/roles/ynh_setup/defaults/main.yml index 355c99f..67c1244 100644 --- a/roles/ynh_setup/defaults/main.yml +++ b/roles/ynh_setup/defaults/main.yml @@ -23,6 +23,15 @@ ynh_install_script_url: https://install.yunohost.org ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS +ynh_dir: "/data/yunohost" + +ynh_data_dirs: + - path: "{{ ynh_dir }}/etc" + link: "/etc/yunohost" + - path: "{{ ynh_dir }}/var" + link: "/var/www" +ynh_data_dirs_enabled: True + # The list of Yunohost domains. ynh_main_domain: domain.tld ynh_extra_domains: null diff --git a/roles/ynh_setup/tasks/main.yml b/roles/ynh_setup/tasks/main.yml index 0105337..a2d22ba 100644 --- a/roles/ynh_setup/tasks/main.yml +++ b/roles/ynh_setup/tasks/main.yml @@ -27,40 +27,28 @@ tags: - pkg - linux - - yunohost -- name: Create apps and config directories +- name: Create data and config subdirs of Yunohost ansible.builtin.file: - path: "{{ item }}" + path: "{{ item.path }}" state: directory - mode: 0770 - loop: - - "{{ ynh_symlink.appdata_dir }}" - - "{{ ynh_symlink.conf_dir }}" + mode: "0755" + with_items: + - "{{ ynh_data_dirs }}" tags: - linux - - yunohost - when: ynh_symlink.enabled + when: ynh_data_dirs_enabled -- name: Create symbolic link for Yunohost apps data directory +- name: Create symbolic links for Yunohost subdirs ansible.builtin.file: - src: /var/www/ - dest: "{{ ynh_symlink.appdata_dir }}/www_symlink" + src: "{{ item.path }}" + dest: "{{ item.link }}" state: link + with_items: + - "{{ ynh_data_dirs }}" tags: - linux - - yunohost - when: ynh_symlink.enabled - -- name: Create symbolic link for Yunohost configuration directory - ansible.builtin.file: - src: /etc/yunohost/ - dest: "{{ ynh_symlink.conf_dir }}/yunohost_symlink" - state: link - tags: - - linux - - yunohost - when: ynh_symlink.enabled + when: ynh_data_dirs_enabled - name: Test if Yunohost is already installed ansible.builtin.stat: path=/etc/yunohost/installed