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

feat: add ynh_autoupdate script

parent 522e0aa8
No related branches found
No related tags found
1 merge request!18✅Resolve "How to auto update apps"
Pipeline #3525 passed with warnings
......@@ -131,10 +131,24 @@ Cette tâche utilisant le module template, vous pouvez tout à fait utiliser vos
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
### 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
```
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`: Cette variable est obligatoire. Elle permet de préciser quand vous souhaitez que cette tâche soit exécutée. Pour en savoir plus sur les special times, cliquez [ici](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html)
- `ynh_autoupdate.scheduled` : Activez la tâche cron en mettant la valeur à `True`.
- `ynh_autoupdate.special_time`: est indispensable. 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 indispensable. Activez la mise à jour automatique des applications Yunohost en mettant la valeur à `True`.
- `ynh_autoupdate.system` : est indispensable. Activez la mise à jour automatique du système Yunohost en mettant la valeur à `True`.
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).
......
......@@ -131,10 +131,22 @@ Because this task uses the template module, you can use your own variables and c
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
### 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
```
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` : Enable the cron job by setting the value to "true".
- `ynh_autoupdate.special_time`: This variable is mandatory. It allows you to specify when you want this task to be executed. To learn more about special times, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html)
- `ynh_autoupdate.scheduled` : Enable 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 required. Enable automatic updating of Yunohost applications by setting the value to `True`.
- `ynh_autoupdate.system`: is required. Enable automatic updating of the Yunohost system by setting the value to `True`.
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.
......
......@@ -65,5 +65,7 @@ ynh_apps: null
# Autoupdate Yunohost and its apps
ynh_autoupdate:
scheduled: "false"
special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
scheduled: False
# special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
# apps: False
# system: False
\ No newline at end of file
---
#-----------------------------------------------------------------------------#
# 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: "/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: "/usr/local/bin/ynh_autoupdate.sh"
......@@ -73,14 +73,6 @@
ansible.builtin.include_tasks: apps.yml
when: ynh_apps
- name: Creates a 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: "yunohost tools update && \
yunohost tools upgrade system && \
yunohost tools upgrade apps"
cron_file: ynh_autoupdate_cron
when: ynh_autoupdate.scheduled == "true"
- name: Configures Yunohost autoupdate
ansible.builtin.include_tasks: autoupdate.yml
when: ynh_autoupdate.scheduled
#!/bin/sh
{% if ynh_autoupdate.apps and ynh_autoupdate.system %}
yunohost tools update && \
yunohost tools upgrade system && \
yunohost tools upgrade apps
{% elif ynh_autoupdate.apps %}
yunohost tools update && \
yunohost tools upgrade apps
{% elif ynh_autoupdate.system %}
yunohost tools update && \
yunohost tools upgrade system
{% else %}
echo "Read the readme to know more about ynh_autoupdate.apps and ynh_autoupdate.system"
exit 1
{% endif %}
\ No newline at end of file
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