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 49d31c08 authored by Arthur BOUDREAULT's avatar Arthur BOUDREAULT
Browse files

refactor: restructuring role into collection #1

parent 12a76db9
No related branches found
No related tags found
No related merge requests found
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
# -*- coding: utf-8 -*-
# Doc: https://docs.gitlab.com/ce/ci/yaml/#include
include:
- project: 'froggit/ci/gci-tpl'
ref: 0.0.1
file:
- '/templates/stages.yml'
- '/templates/job/ansible/lint.yml'
# No playbook in this repo
ansible-syntax-check:
rules:
- when: never
This diff is collapsed.
[![](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)
# Rôle Ansible : Yunohost
[🇬🇧 English version](README.md)
Déployez [Yunohost](https://yunohost.org/#/) avec Ansible !
## Prérequis
Aucun.
## Variables du rôle
Les variables par défaut sont disponibles dans `default/main.yml` cependant il est nécessaire de les surcharger selon vos besoins en termes de domaines, d'utilisateurs et d'applications sur Yunohost.
### Installation de Yunohost
```yml
# Script pour Debian 10 uniquement.
ynh_install_script_url: https://install.yunohost.org
ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
```
- `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.
### Gestion des domaines
```yml
# Liste des domaines gérés par Yunohost.
ynh_main_domain: domain.tld
ynh_extra_domains:
- forum.domain.tld
- wiki.domain.tld
ynh_ignore_dyndns_server: False
```
- `ynh_main_domain` correspond au domaine principal qui permet l’accès au serveur ainsi qu’au portail d’authentification des utilisateurs. On peut se contenter d'un nom de domaine qui nous appartient ou en utiliser un en .nohost.me / .noho.st / .ynh.fr (plus d'infos [ici](https://yunohost.org/fr/install/hardware:vps_debian)).
- `ynh_extra_domains` sont des sous-domaines optionnels. Ils permettent d'installer une application par sous-domaine (plus d'infos [ici](https://yunohost.org/fr/dns_subdomains)).
- `ynh_ignore_dyndns_server` permet d'enregistrer les domaines avec un service de DNS dynamique (plus d'infos [ici](https://yunohost.org/fr/dns_dynamicip)).
### Configuration d'un relais SMTP
```yml
# paramètres personnalisés du relais SMTP
ynh_smtp_relay:
host: smtp.domain.tld
port: 25
user: user1
password: Pa$$w0rd
```
Yunohost possède son propre serveur SMTP natif mais il est aussi possible de configurer Yunohost pour qu'il utilise un relais SMTP à la place.
Pour faire cela, créez la variable `ynh_smtp_relay` et mettez vos propres valeurs. Vous pouvez en apprendre plus sur les relais SMTP [ici](https://yunohost.org/fr/administrate/specific_use_cases/email_relay).
### Gestion des utilisateurs
```yml
# Liste des utilisateurs Yunohost.
ynh_users:
- name: user1
pass: MYINSECUREPWD_PLZ_OVERRIDE_THIS
firstname: Jane
lastname: Doe
mail_domain: domain.tld
```
- `ynh_users` est la liste des utilisateurs à créer. Chaque champ est obligatoire. Certaines applications Yunohost nécessitent qu'un utilisateur soit administrateur de l'application. Il aura ensuite le droit de gérer l'application depuis l'interface l'administration du serveur. Vous pouvez en apprendre plus sur la gestion des utilisateurs Yunohost [ici](https://yunohost.org/fr/administrate/overview/users).
### Gestion des applications
```yml
# Liste des applications Yunohost.
ynh_apps:
- label: WikiJS
link: wikijs
args:
domain: wiki.domain.tld
path: /
admin: user1
is_public: no
- label: Discourse
link: discourse
args:
domain: forum.domain.tld
path: /
admin: user1
is_public: yes
post_install:
- src: "templates/site_settings.yml.j2"
dest: "/var/www/discourse/config/site_settings.yml"
type: "config"
- src: "templates/configure_discourse.sh.j2"
dest: "/tmp/configure_discourse.sh"
type: "script"
owner: root
group: root
```
- `ynh_apps` est la liste des applications à installer.
- `label` permet de donner un nom personnalisé à l'application sur l'interface utilisateur.
- `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.
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é.
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).
- `src` est obligatoire. Il s'agit du répertoire où le fichier de template se situe sur la machine qui execute Ansible.
- `dest` est obligatoire. Il s'agit du répertoire où le fichier de template va être stocké.
- `type` est obligatoire :
- Si vous précisez comme valeur `script` alors le fichier de template aura pour droits 740. Il sera exécuté après son transfert sur le serveur Yunohost (généralement dans `/tmp/`) puis il sera supprimé.
- Si vous précisez comme valeur `config` alors le fichier de template aura pour droits 660. Il sera transféré sur le serveur Yunohost (généralement dans `/var/www/AppName/`) et vous pourrez l'importer avec un script shell à côté par exemple.
Pour `owner` et `group`, par défaut le fichier va prendre comme utilisateur propriétaire le nom de l'application et comme groupe propriétaire www-data (groupe NGINX). Vous pouvez les changer en précisant des valeurs différentes.
### Concernant les mises à jour
```yml
# Autoupdate Yunohost and its apps
ynh_autoupdate:
scheduled: True
special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
apps: True
system: True
dest_script: "/usr/bin/"
```
Une tâche cron peut être mise en place pour automatiser la vérification des mises à jour système et applications suivant la périodicité de votre choix.
- `ynh_autoupdate.scheduled` : activez la tâche cron en mettant la valeur à `True`.
- `ynh_autoupdate.special_time`: est obligatoire. Elle permet de préciser quand vous souhaitez que cette tâche soit exécutée. Valeurs possibles : (`annually`,`daily`,`hourly`,`monthly`,`reboot`,`weekly`,`yearly`).
Pour en savoir plus sur les _special times_, cliquez [ici](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html).
- `ynh_autoupdate.apps` : est obligatoire. Activez la mise à jour automatique des applications Yunohost en mettant la valeur à `True`.
- `ynh_autoupdate.system` : est obligatoire. Activez la mise à jour automatique du système Yunohost en mettant la valeur à `True`.
- `ynh_autoupdate.dest_script` : c'est le chemin du répertoire où le script de mise à jour sera installé sur le serveur. La valeur par défaut est `/usr/local/bin`. Le script s'appelle `ynh_autoupdate.sh`.
Si des mises à jour sont disponibles, elles sont faites automatiquement. En cas de problème suite à la mise à jour d'une application, vous pouvez lire les logs qui sont disponibles ici `/var/log/yunohost/categories/operation`. Vous avez aussi la possibilité de revenir à la version précédente car Yunohost fait toujours une sauvegarde automatique d'une application lorsqu'elle est mise à jour.
Pour en savoir plus sur le fonctionnement des mises à jour dans Yunohost vous pouvez vous rendre [ici](https://yunohost.org/fr/update). Le changelog des versions de Yunohost est aussi disponible [ici](https://forum.yunohost.org/tag/ynh_release).
## Dépendances
Aucune.
## Exemple de Playbook
```yml
---
- name: Install Yunohost on Debian Server
hosts: all
become: True
pre_tasks:
- name: Update all packages and index
ansible.builtin.apt:
upgrade: dist
update_cache: yes
roles:
- lydra.yunohost
```
## 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.
[![](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 Role: Yunohost
[🇫🇷 French version](README-FR.md)
Deploy [Yunohost](https://yunohost.org/#/) with Ansible!
## Requirements
None.
## Role Variables
Default variables are available in `default/main.yml` however it is necessary to override them according to your needs for Yunohost domains, users and apps.
### Yunohost Installation
```yml
# Debian 10 script only.
ynh_install_script_url: https://install.yunohost.org
ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
```
- `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.
### Domain management
```yml
# The list of Yunohost domains.
ynh_main_domain: domain.tld
ynh_extra_domains:
- forum.domain.tld
- wiki.domain.tld
ynh_ignore_dyndns_server: False
```
- `ynh_main_domain` is the main domain used by the server's users to access the authentication portal. If you already own a domain name, you probably want to use it here. You can also use a domain in .nohost.me / .noho.st / .ynh.fr (more info [here](https://yunohost.org/en/install/hardware:vps_debian)).
- `ynh_extra_domains` are optional and allow you to install one app per subdomain (more info [here](https://yunohost.org/en/administrate/specific_use_cases/domains/dns_subdomains)).
- `ynh_ignore_dyndns_server` allow to register domains with a Dynamic DNS service (more info [here](https://yunohost.org/en/dns_dynamicip)).
### SMTP relay configuration
```yml
# SMTP custom settings
ynh_smtp_relay:
host: smtp.domain.tld
port: 25
user: user1
password: Pa$$w0rd
```
There is a built-in SMTP server on Yunohost but you can also set up Yunohost to use a SMTP relay instead.
In order to do so, create the `ynh_smtp_relay` variable and provide your own values. You can learn more about SMTP relay [here](https://yunohost.org/en/administrate/specific_use_cases/email_relay).
### User management
```yml
# The list of Yunohost users.
ynh_users:
- name: user1
pass: MYINSECUREPWD_PLZ_OVERRIDE_THIS
firstname: Jane
lastname: Doe
mail_domain: domain.tld
```
- `ynh_users` is the list of users to create. Each field is mandatory. Some Yunohost applications require that a user be the app administrator. He will then have the right to manage the application from the server administration interface. You can learn more about Yunohost user management [here](https://yunohost.org/en/users).
### App management
```yml
# The list of Yunohost apps.
ynh_apps:
- label: WikiJS
link: wikijs
args:
domain: wiki.domain.tld
path: /
admin: user1
is_public: no
- label: Discourse
link: discourse
args:
domain: forum.domain.tld
path: /
admin: user1
is_public: yes
post_install:
- src: "templates/site_settings.yml.j2"
dest: "/var/www/discourse/config/site_settings.yml"
type: "config"
- src: "templates/configure_discourse.sh.j2"
dest: "/tmp/configure_discourse.sh"
type: "script"
owner: root
group: root
```
- `ynh_apps` is the list of applications to install.
- `label` allows you to give a custom name to the application on the user interface.
- `link` is the name of the Yunohost application to install.
#### About the arguments
- `domain` is essential. You have to choose one of the domains of your Yunohost instance.
- `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).
#### About the post-installation
It is possible to complete the installation of applications by adding jinja template configuration files or scripts written by yourself.
To enable this feature, define the `post_install` variable which corresponds to the list of post-installation files of your applications.
Because this task uses the template module, you can use your own variables and call them in your template files. To know more about this module, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html).
- `src` is mandatory. This is the directory where the template file is located on the machine running Ansible.
- `dest` is mandatory. This is the directory where the template file will be stored.
- `type` is mandatory:
- If you specify `script` as the value, then the template file will have 740 rights. It will be executed after it is transferred to the Yunohost server (usually in `/tmp/`) and then deleted.
- If you specify `config` as the value, then the template file will have 660 rights. It will be transferred to the Yunohost server (usually in `/var/www/AppName/`) and after you could import it with a shell script on the side for example.
For `owner` and `group`, by default the file will take as owner the name of the application and as owner www-data(NGINX group). You can change them by specifying different values.
### About the updates
```yml
# Autoupdate Yunohost and its apps
ynh_autoupdate:
scheduled: True
special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
apps: True
system: True
dest_script: "/usr/bin/"
```
A cron job can been set up to automate the check for system and application updates on a schedule of your choice.
- `ynh_autoupdate.scheduled` : enables the cron job by setting the value to `True`.
- `ynh_autoupdate.special_time`: it is mandatory. It allows you to specify when you want this task to be executed. Possible values: (`annually`,`daily`,`hourly`,`monthly`,`reboot`,`weekly`,`yearly`). To learn more about special times, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html).
- `ynh_autoupdate.apps`: is mandatory. Enable automatic updating of Yunohost applications by setting the value to `True`.
- `ynh_autoupdate.system`: is mandatory. Enable 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.
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).
## Dependencies
None.
## Example Playbook
```yml
---
- name: Install Yunohost on Debian Server
hosts: all
become: True
pre_tasks:
- name: Update all packages and index
ansible.builtin.apt:
upgrade: dist
update_cache: yes
roles:
- ansible-yunohost
```
## 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** is maintained by [Lydra](https://lydra.fr/) and released under the GPL3 license.
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
# Debian 10 script only.
ynh_install_script_url: https://install.yunohost.org
ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
# The list of Yunohost domains.
ynh_main_domain: domain.tld
ynh_extra_domains: null
ynh_ignore_dyndns_server: False
# The list of Yunohost users.
ynh_users: null
# - name: user1
# pass: p@ssw0rd
# firstname: Jane
# lastname: Doe
# mail_domain: domain.tld
# Do not touch this variable
# Just to have dict default value
ynh_smtp_relay:
value: null
# SMTP custom settings (Only override if you need a SMTP relay)
# Example:
# ynh_smtp_relay:
# host: smtp.domain.tld
# port: "25"
# user: user1
# password: Pa$$w0rd
# The list of Yunohost apps.
ynh_apps: null
# - label: Tiny Tiny RSS
# link: ttrss
# args:
# domain: domain.tld
# path: /ttrss
# post_install:
# - src: "templates/file.sh.j2"
# dest: "/tmp/script.sh"
# type: script
# owner: ttrss # Only provide if different from app name
# group: ttrss # Only provide if different from www-data
# Autoupdate Yunohost and its apps
ynh_autoupdate:
scheduled: False
# special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
# apps: True
# system: True
# dest_script: "/usr/local/bin/"
---
galaxy_info:
role_name: yunohost
author: lydra
description: Deploy Yunohost with Ansible
license: GPL-v3
min_ansible_version: 2.10
github_branch: main
platforms:
- name: Debian
versions:
- buster
galaxy_tags:
- yunohost
- cloud
- web
dependencies: []
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
# Installation part
- name: Install yunohost apps
ansible.builtin.command: yunohost app install {{ ynh_app.link }} \
--label "{{ ynh_app.label }}" \
--args "{% for key, value in ynh_app.args.items() %}{{ key }}={{ value }}{% if not loop.last %}&{% endif %}{% endfor %}"
changed_when: False
# Post-installation part
- name: Create post-install template
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "{{ item.owner | default(ynh_app.link) }}"
group: "{{ item.group | default('www-data') }}"
mode: "{{ (item.type == 'script') | ternary('740', '660') }}"
loop: "{{ ynh_app.post_install|default([]) }}"
when: ynh_app.post_install
- name: Launch post-install script
ansible.builtin.command: "{{ ynh_app_post_install.dest }}"
args:
chdir: /tmp/
loop: "{{ ynh_app.post_install|default([]) }}"
loop_control:
loop_var: ynh_app_post_install
when: ynh_app_post_install.type == "script"
- name: Remove script after execution
ansible.builtin.file:
path: "{{ ynh_app_post_install.dest }}"
state: absent
loop: "{{ ynh_app.post_install|default([]) }}"
loop_control:
loop_var: ynh_app_post_install
when: ynh_app_post_install.type == "script"
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: List currently installed apps
ansible.builtin.command: yunohost app map --output-as json
register: ynh_installed_apps_raw
changed_when: False
- name: Format json of apps
ansible.builtin.set_fact: ynh_installed_apps="{{ ynh_installed_apps_raw.stdout | from_json }}"
- name: Install yunohost apps and perform post-install
ansible.builtin.include_tasks: app.yml
loop: "{{ ynh_apps }}"
loop_control:
loop_var: ynh_app
when: ynh_app.label not in ynh_installed_apps.values()
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: Creates Yunohost autoupdate script
ansible.builtin.template:
src: "templates/ynh_autoupdate.sh.j2"
dest: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/') }}ynh_autoupdate.sh"
owner: root
group: root
mode: '0740'
- name: Creates cron task under /etc/cron.d to auto-update Yunohost
ansible.builtin.cron:
name: "auto-update Yunohost
Logs can be found in /var/log/yunohost/categories/operation"
special_time: "{{ ynh_autoupdate.special_time }}"
user: root
job: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/') }}ynh_autoupdate.sh"
cron_file: ynh_autoupdate_cron
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: List currently installed domains
ansible.builtin.command: yunohost domain list --output-as json
register: ynh_installed_domains_raw
changed_when: False
- name: Format json of domains
ansible.builtin.set_fact: ynh_installed_domains="{{ ynh_installed_domains_raw.stdout | from_json }}"
- name: Create domains
ansible.builtin.command: yunohost domain add {{ item }}
with_items: "{{ ynh_extra_domains }}"
when: item not in ynh_installed_domains.domains
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: Install requirements
ansible.builtin.apt:
name:
- git
- dialog
state: present
- name: Test if Yunohost is already installed
ansible.builtin.stat: path=/etc/yunohost/installed
register: ynh_file_install
- name: Download Yunohost install script
ansible.builtin.get_url:
url: "{{ ynh_install_script_url }}"
dest: /tmp/install_yunohost.sh
mode: 700
when: not ynh_file_install.stat.exists
- name: Launch Yunohost install script
ansible.builtin.command: /tmp/install_yunohost.sh -a
when: not ynh_file_install.stat.exists
- name: Launch Yunohost postinstall
ansible.builtin.command:
yunohost tools postinstall \
--domain "{{ ynh_main_domain }}" \
--password "{{ ynh_admin_password }}" \
{% if ynh_ignore_dyndns_server %} --ignore-dyndns {% endif %}
when: not ynh_file_install.stat.exists
- name: Create extra domains
ansible.builtin.include_tasks: domains.yml
when: ynh_extra_domains
- name: Run first Yunohost diagnosis
ansible.builtin.command: yunohost diagnosis run
when: not ynh_file_install.stat.exists
- name: Install domain certificates
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
- 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
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: Get current SMTP settings
ansible.builtin.command:
"yunohost settings get smtp.relay.{{ item.key }}"
register: _ynh_smtp_current_values
changed_when: False
- name: Set new SMTP settings
ansible.builtin.command:
"yunohost settings set smtp.relay.{{ item.key }} -v {{ item.value }}"
when: _ynh_smtp_current_values.stdout != item.value
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-2021 Lydra https://www.lydra.fr/ #
# #
# this program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# this program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: List users
ansible.builtin.command: yunohost user list --output-as json
register: ynh_registered_users_raw
changed_when: False
- name: Format json of users
ansible.builtin.set_fact: ynh_registered_users="{{ ynh_registered_users_raw.stdout | from_json }}"
- name: Create missing Yunohost users
ansible.builtin.command:
yunohost user create "{{ item.name }}" \
-f "{{ item.firstname }}" \
-l "{{ item.lastname }}" \
-d "{{ item.mail_domain }}" \
-p "{{ item.pass }}"
loop: "{{ ynh_users }}"
when: item.name not in ynh_registered_users.users.keys()
#!/bin/sh
yunohost tools update
{% if ynh_autoupdate.system %}
yunohost tools upgrade system
{% endif %}
{% if ynh_autoupdate.apps %}
yunohost tools upgrade apps
{% endif %}
{% if ynh_autoupdate.system is false and ynh_autoupdate.apps is false %}
echo "Read the readme to know more about ynh_autoupdate.apps and ynh_autoupdate.system"
echo "https://lab.frogg.it/lydra/yunohost/ansible-yunohost/-/blob/main/README.md"
exit 1
{% endif %}
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