Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit e6cbbbda authored by Arthur BOUDREAULT's avatar Arthur BOUDREAULT
Browse files

refactor: restructuring role into collection #6

parent 65541ed1
No related branches found
No related tags found
No related merge requests found
Pipeline #3696 failed
This commit is part of merge request !22. Comments created here will be created in the context of that merge request.
Showing
with 141 additions and 21 deletions
...@@ -13,20 +13,35 @@ ...@@ -13,20 +13,35 @@
[🇬🇧 English version](README.md) [🇬🇧 English version](README.md)
Cette collection vise à installer, configurer et sauvegarder [Yunohost](https://yunohost.org/#/). 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. Comme il s'agit d'une collection indépendante, elle peut être publiée selon sa propre cadence de publication. De plus, les rôles qu'elle contient sont mis à jour indépendamment.
## Prérequis ## Prérequis
Votre serveur doit être basé sur du Debian Buster. Votre serveur doit être basé sur du Debian Buster et Yunohost ne doit pas déjà être installé.
## Contenu de la collection ## Contenu de la collection
### Rôles ### Rôles
- `lydra.yunohost.ynh_setup` : Ce rôle prépare les serveurs à base de Debian-Buster à exécuter Yunohost. - `lydra.yunohost.ynh_setup` : Ce rôle prépare les serveurs à base de Debian-Buster à exécuter Yunohost. Il configure Yunohost avec ses paramètres initiaux et les domaines, utilisateurs et applications de votre choix.
- `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_config` : Ce rôle gère la configuration de différents services de Yunohost (relais SMTP, mises à jour automatiques).
- `lydra.yunohost.ynh_backup` : Ce rôle gère la configuration des sauvegardes. - `lydra.yunohost.ynh_backup` : Ce rôle gère la configuration des sauvegardes.
### lydra.yunohost Tags du rôle
Ces tags sont applicables suivant les rôles.
|tags|commentaires|
|----|-------|
|yunohost|Tâches spécifiques à Yunohost.|
|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.|
## License ## 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 Copyright 2021 Lydra](https://www.gnu.org/graphics/gplv3-with-text-136x68.png)](https://choosealicense.com/licenses/gpl-3.0/)
......
...@@ -13,19 +13,34 @@ ...@@ -13,19 +13,34 @@
[🇫🇷 French version](README-FR.md) [🇫🇷 French version](README-FR.md)
This collection aims at installing, configuring and backing up [Yunohost](https://yunohost.org/#/). 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. As this is an independent collection, it can be released on its own release cadence. Moreover, the roles it contains are updated independently.
# Prerequisites # Prerequisites
Your server must be Debian-Buster based. Your server must be Debian-Buster based and Yunohost shouldn't be already installed.
## Collection contents ## Collection contents
### Roles ### Roles
- `lydra.yunohost.ynh_setup` : This role prepares servers with Debian-Buster-based to run Yunohost. - `lydra.yunohost.ynh_setup` : This role prepares servers with Debian-Buster-based to run Yunohost. It sets up Yunohost with its initial settings and domains, users and apps of your choice.
- `lydra.yunohost.ynh_config` : This role manages configuring and starting various Yunohost services (SMTP relay, auto updates). - `lydra.yunohost.ynh_config` : This role configures various Yunohost services (SMTP relay, auto updates).
- `lydra.yunohost.ynh_backup` : This role manages configuring of backups. - `lydra.yunohost.ynh_backup` : This role manages the configuration of backups.
## lydra.yunohost Role Tags
These tags are applicable to roles.
|tags|comment|
|----|-------|
|yunohost|Tasks specific to Yunohost.|
|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.|
## License ## License
......
...@@ -56,17 +56,13 @@ Aucune. ...@@ -56,17 +56,13 @@ Aucune.
```yml ```yml
--- ---
- name: Install Yunohost on Debian Server - name: Configure Yunohost backups
hosts: all hosts: all
become: True become: True
pre_tasks: collections:
- name: Update all packages and index
ansible.builtin.apt:
upgrade: dist
update_cache: yes
roles:
- lydra.yunohost - lydra.yunohost
roles:
- ynh_backup
``` ```
## License ## License
......
...@@ -59,6 +59,8 @@ None. ...@@ -59,6 +59,8 @@ None.
- name: Install Yunohost on Debian Server - name: Install Yunohost on Debian Server
hosts: all hosts: all
become: True become: True
collections:
- lydra.yunohost
pre_tasks: pre_tasks:
- name: Update all packages and index - name: Update all packages and index
ansible.builtin.apt: ansible.builtin.apt:
...@@ -66,7 +68,7 @@ None. ...@@ -66,7 +68,7 @@ None.
update_cache: yes update_cache: yes
roles: roles:
- ansible-yunohost - ynh_backup
``` ```
## License ## License
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
path: "{{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}" path: "{{ ynh_backup.directory | default('/home/yunohost.backup/archives') }}"
state: directory state: directory
mode: '0750' mode: '0750'
tags:
- "backup"
- name: Create backup script - name: Create backup script
ansible.builtin.template: ansible.builtin.template:
...@@ -31,6 +33,9 @@ ...@@ -31,6 +33,9 @@
owner: root owner: root
group: root group: root
mode: '0740' mode: '0740'
tags:
- "backup"
- "cron"
- name: Create cron task to perform YNH backup - name: Create cron task to perform YNH backup
ansible.builtin.cron: ansible.builtin.cron:
...@@ -42,3 +47,6 @@ ...@@ -42,3 +47,6 @@
user: root user: root
job: "{{ ynh_backup.dest_script | default('/usr/local/bin/') }}ynh_backup.sh" job: "{{ ynh_backup.dest_script | default('/usr/local/bin/') }}ynh_backup.sh"
cron_file: ynh_backup_cron cron_file: ynh_backup_cron
tags:
- "backup"
- "cron"
...@@ -21,3 +21,5 @@ ...@@ -21,3 +21,5 @@
- name: Enable Yunohost apps backup - name: Enable Yunohost apps backup
ansible.builtin.include_tasks: backup.yml ansible.builtin.include_tasks: backup.yml
when: ynh_backup.scheduled when: ynh_backup.scheduled
tags:
- "backup"
...@@ -68,9 +68,11 @@ Aucune. ...@@ -68,9 +68,11 @@ Aucune.
```yml ```yml
--- ---
- name: Configure Yunohost on Debian Server - name: Install Yunohost on Debian Server
hosts: all hosts: all
become: True become: True
collections:
- lydra.yunohost
pre_tasks: pre_tasks:
- name: Update all packages and index - name: Update all packages and index
ansible.builtin.apt: ansible.builtin.apt:
...@@ -78,7 +80,7 @@ Aucune. ...@@ -78,7 +80,7 @@ Aucune.
update_cache: yes update_cache: yes
roles: roles:
- lydra.yunohost - ynh_config
``` ```
## License ## License
......
...@@ -71,6 +71,8 @@ None. ...@@ -71,6 +71,8 @@ None.
- name: Install Yunohost on Debian Server - name: Install Yunohost on Debian Server
hosts: all hosts: all
become: True become: True
collections:
- lydra.yunohost
pre_tasks: pre_tasks:
- name: Update all packages and index - name: Update all packages and index
ansible.builtin.apt: ansible.builtin.apt:
...@@ -78,7 +80,7 @@ None. ...@@ -78,7 +80,7 @@ None.
update_cache: yes update_cache: yes
roles: roles:
- ansible-yunohost - ynh_config
``` ```
## License ## License
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
owner: root owner: root
group: root group: root
mode: '0740' mode: '0740'
tags:
- "update"
- "cron"
- name: Creates cron task under /etc/cron.d to auto-update Yunohost - name: Creates cron task under /etc/cron.d to auto-update Yunohost
ansible.builtin.cron: ansible.builtin.cron:
...@@ -34,3 +37,6 @@ ...@@ -34,3 +37,6 @@
user: root user: root
job: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/') }}ynh_autoupdate.sh" job: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/') }}ynh_autoupdate.sh"
cron_file: ynh_autoupdate_cron cron_file: ynh_autoupdate_cron
tags:
- "update"
- "cron"
...@@ -22,7 +22,11 @@ ...@@ -22,7 +22,11 @@
ansible.builtin.include_tasks: smtp_relay.yml ansible.builtin.include_tasks: smtp_relay.yml
loop: "{{ ynh_smtp_relay | dict2items }}" loop: "{{ ynh_smtp_relay | dict2items }}"
when: item.value when: item.value
tags:
- "smtp"
- name: Configures Yunohost autoupdate - name: Configures Yunohost autoupdate
ansible.builtin.include_tasks: autoupdate.yml ansible.builtin.include_tasks: autoupdate.yml
when: ynh_autoupdate.scheduled when: ynh_autoupdate.scheduled
tags:
- "update"
...@@ -23,8 +23,12 @@ ...@@ -23,8 +23,12 @@
"yunohost settings get smtp.relay.{{ item.key }}" "yunohost settings get smtp.relay.{{ item.key }}"
register: _ynh_smtp_current_values register: _ynh_smtp_current_values
changed_when: False changed_when: False
tags:
- "smtp"
- name: Set new SMTP settings - name: Set new SMTP settings
ansible.builtin.command: ansible.builtin.command:
"yunohost settings set smtp.relay.{{ item.key }} -v {{ item.value }}" "yunohost settings set smtp.relay.{{ item.key }} -v {{ item.value }}"
when: _ynh_smtp_current_values.stdout != item.value when: _ynh_smtp_current_values.stdout != item.value
tags:
- "smtp"
...@@ -141,6 +141,8 @@ Aucune. ...@@ -141,6 +141,8 @@ Aucune.
roles: roles:
- ynh_setup - ynh_setup
- ynh_config
- ynh_backup
``` ```
## License ## License
......
...@@ -141,6 +141,8 @@ None. ...@@ -141,6 +141,8 @@ None.
roles: roles:
- ynh_setup - ynh_setup
- ynh_config
- ynh_backup
``` ```
## License ## License
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
--label "{{ ynh_app.label }}" \ --label "{{ ynh_app.label }}" \
--args "{% for key, value in ynh_app.args.items() %}{{ key }}={{ value }}{% if not loop.last %}&{% endif %}{% endfor %}" --args "{% for key, value in ynh_app.args.items() %}{{ key }}={{ value }}{% if not loop.last %}&{% endif %}{% endfor %}"
changed_when: False changed_when: False
tags:
- "yunohost"
- "apps"
# Post-installation part # Post-installation part
- name: Create post-install template - name: Create post-install template
...@@ -35,6 +38,8 @@ ...@@ -35,6 +38,8 @@
mode: "{{ (item.type == 'script') | ternary('740', '660') }}" mode: "{{ (item.type == 'script') | ternary('740', '660') }}"
loop: "{{ ynh_app.post_install|default([]) }}" loop: "{{ ynh_app.post_install|default([]) }}"
when: ynh_app.post_install when: ynh_app.post_install
tags:
- "apps"
- name: Launch post-install script - name: Launch post-install script
ansible.builtin.command: "{{ ynh_app_post_install.dest }}" ansible.builtin.command: "{{ ynh_app_post_install.dest }}"
...@@ -44,6 +49,8 @@ ...@@ -44,6 +49,8 @@
loop_control: loop_control:
loop_var: ynh_app_post_install loop_var: ynh_app_post_install
when: ynh_app_post_install.type == "script" when: ynh_app_post_install.type == "script"
tags:
- "apps"
- name: Remove script after execution - name: Remove script after execution
ansible.builtin.file: ansible.builtin.file:
...@@ -53,3 +60,5 @@ ...@@ -53,3 +60,5 @@
loop_control: loop_control:
loop_var: ynh_app_post_install loop_var: ynh_app_post_install
when: ynh_app_post_install.type == "script" when: ynh_app_post_install.type == "script"
tags:
- "apps"
...@@ -22,9 +22,15 @@ ...@@ -22,9 +22,15 @@
ansible.builtin.command: yunohost app map --output-as json ansible.builtin.command: yunohost app map --output-as json
register: ynh_installed_apps_raw register: ynh_installed_apps_raw
changed_when: False changed_when: False
tags:
- "yunohost"
- "apps"
- name: Format json of apps - name: Format json of apps
ansible.builtin.set_fact: ynh_installed_apps="{{ ynh_installed_apps_raw.stdout | from_json }}" ansible.builtin.set_fact: ynh_installed_apps="{{ ynh_installed_apps_raw.stdout | from_json }}"
tags:
- "yunohost"
- "apps"
- name: Install yunohost apps and perform post-install - name: Install yunohost apps and perform post-install
ansible.builtin.include_tasks: app.yml ansible.builtin.include_tasks: app.yml
...@@ -32,4 +38,7 @@ ...@@ -32,4 +38,7 @@
loop_control: loop_control:
loop_var: ynh_app loop_var: ynh_app
when: ynh_app.label not in ynh_installed_apps.values() when: ynh_app.label not in ynh_installed_apps.values()
tags:
- "yunohost"
- "apps"
...@@ -22,11 +22,20 @@ ...@@ -22,11 +22,20 @@
ansible.builtin.command: yunohost domain list --output-as json ansible.builtin.command: yunohost domain list --output-as json
register: ynh_installed_domains_raw register: ynh_installed_domains_raw
changed_when: False changed_when: False
tags:
- "yunohost"
- "domains"
- name: Format json of domains - name: Format json of domains
ansible.builtin.set_fact: ynh_installed_domains="{{ ynh_installed_domains_raw.stdout | from_json }}" ansible.builtin.set_fact: ynh_installed_domains="{{ ynh_installed_domains_raw.stdout | from_json }}"
tags:
- "yunohost"
- "domains"
- name: Create domains - name: Create domains
ansible.builtin.command: yunohost domain add {{ item }} ansible.builtin.command: yunohost domain add {{ item }}
with_items: "{{ ynh_extra_domains }}" with_items: "{{ ynh_extra_domains }}"
when: item not in ynh_installed_domains.domains when: item not in ynh_installed_domains.domains
tags:
- "yunohost"
- "domains"
...@@ -24,10 +24,14 @@ ...@@ -24,10 +24,14 @@
- git - git
- dialog - dialog
state: present state: present
tags:
- "pkg"
- name: Test if Yunohost is already installed - name: Test if Yunohost is already installed
ansible.builtin.stat: path=/etc/yunohost/installed ansible.builtin.stat: path=/etc/yunohost/installed
register: ynh_file_install register: ynh_file_install
tags:
- "yunohost"
- name: Download Yunohost install script - name: Download Yunohost install script
ansible.builtin.get_url: ansible.builtin.get_url:
...@@ -35,10 +39,14 @@ ...@@ -35,10 +39,14 @@
dest: /tmp/install_yunohost.sh dest: /tmp/install_yunohost.sh
mode: 700 mode: 700
when: not ynh_file_install.stat.exists when: not ynh_file_install.stat.exists
tags:
- "yunohost"
- name: Launch Yunohost install script - name: Launch Yunohost install script
ansible.builtin.command: /tmp/install_yunohost.sh -a ansible.builtin.command: /tmp/install_yunohost.sh -a
when: not ynh_file_install.stat.exists when: not ynh_file_install.stat.exists
tags:
- "yunohost"
- name: Launch Yunohost postinstall - name: Launch Yunohost postinstall
ansible.builtin.command: ansible.builtin.command:
...@@ -47,23 +55,39 @@ ...@@ -47,23 +55,39 @@
--password "{{ ynh_admin_password }}" \ --password "{{ ynh_admin_password }}" \
{% if ynh_ignore_dyndns_server %} --ignore-dyndns {% endif %} {% if ynh_ignore_dyndns_server %} --ignore-dyndns {% endif %}
when: not ynh_file_install.stat.exists when: not ynh_file_install.stat.exists
tags:
- "yunohost"
- "domains"
- name: Create extra domains - name: Create extra domains
ansible.builtin.include_tasks: domains.yml ansible.builtin.include_tasks: domains.yml
when: ynh_extra_domains when: ynh_extra_domains
tags:
- "yunohost"
- "domains"
- name: Run first Yunohost diagnosis - name: Run first Yunohost diagnosis
ansible.builtin.command: yunohost diagnosis run ansible.builtin.command: yunohost diagnosis run
when: not ynh_file_install.stat.exists when: not ynh_file_install.stat.exists
tags:
- "yunohost"
- name: Install domain certificates - name: Install domain certificates
ansible.builtin.command: yunohost domain cert-install ansible.builtin.command: yunohost domain cert-install
changed_when: False changed_when: False
tags:
- "yunohost"
- name: Add Yunohost users - name: Add Yunohost users
ansible.builtin.include_tasks: users.yml ansible.builtin.include_tasks: users.yml
when: ynh_users when: ynh_users
tags:
- "yunohost"
- "users"
- name: Install Yunohost apps - name: Install Yunohost apps
ansible.builtin.include_tasks: apps.yml ansible.builtin.include_tasks: apps.yml
when: ynh_apps when: ynh_apps
tags:
- "yunohost"
- "apps"
...@@ -22,9 +22,15 @@ ...@@ -22,9 +22,15 @@
ansible.builtin.command: yunohost user list --output-as json ansible.builtin.command: yunohost user list --output-as json
register: ynh_registered_users_raw register: ynh_registered_users_raw
changed_when: False changed_when: False
tags:
- "yunohost"
- "users"
- name: Format json of users - name: Format json of users
ansible.builtin.set_fact: ynh_registered_users="{{ ynh_registered_users_raw.stdout | from_json }}" ansible.builtin.set_fact: ynh_registered_users="{{ ynh_registered_users_raw.stdout | from_json }}"
tags:
- "yunohost"
- "users"
- name: Create missing Yunohost users - name: Create missing Yunohost users
ansible.builtin.command: ansible.builtin.command:
...@@ -35,3 +41,6 @@ ...@@ -35,3 +41,6 @@
-p "{{ item.pass }}" -p "{{ item.pass }}"
loop: "{{ ynh_users }}" loop: "{{ ynh_users }}"
when: item.name not in ynh_registered_users.users.keys() when: item.name not in ynh_registered_users.users.keys()
tags:
- "yunohost"
- "users"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment