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

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • lydra/yunohost/ansible-yunohost
1 result
Show changes
Commits on Source (4)
......@@ -70,6 +70,53 @@ 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.
### Gestion des conteneurs Docker
Par défaut, les applications de YunoHost sont prépackagées par les membres de la communauté. Nous avons décidé d'aller plus loin, en ajoutant simplement la possibilité de déployer des conteneurs Docker à l'aide de Docker Compose et de les intégrer au panel d'applications YunoHost. Nous utilisons pour cela [l'application YunoHost redirect](https://github.com/YunoHost-Apps/redirect_ynh/).
### 1ere étape : Installation et lancement des conteneurs Docker
```yml
enable_ynh_docker: true
geerlingguy_docker_version: 5.2.1
docker_compose_src_template: templates/compose.yml.j2
docker_compose_dest_template: /tmp/compose.yml
docker_compose_version: 3.9
docker_compose_apps:
- name: app1
image: "recordsansible/ara-api:latest"
ports:
- "8000:8000"
volumes:
- "/home/{{ ynh_admin }}/.ara/server:/opt/ara"
environment: null
```
- `enable_ynh_docker` : Active / désactive la fonctionnalité d'installation et de lancement des services Docker Compose.
- `geerlingguy_docker_version`: Vous permet de spécifier la version du rôle Ansible Docker que vous souhaitez utiliser. La version par défaut du rôle est 5.2.1, mais vous pouvez vérifier les versions du rôle [ici](https://github.com/geerlingguy/ansible-role-docker/tags).
- `docker_compose_src_template`: Chemin où se trouve le fichier de template Docker Compose à utiliser. Par défaut, nous fournissons un fichier de template mais vous pouvez aussi fournir votre fichier Docker Compose personnalisé.
- `docker_compose_dest_template` : Chemin où va être le fichier Docker Compose sur la machine distante.
- `docker_compose_version` : Version de Docker Compose utilisée pour le fichier. Valeur par défaut: `3.9`.
- `docker_compose_apps` : Dictionnaires d'un ou plusieurs services Docker Compose. Dans chaque dictionnaire vous pourrez définir : name (obligatoire), image (obligatoire), ports (optionnel), volumes (optionnel) et environment (optionnel, variables d'environnement). Si vous ne définissez pas un des clés optionnelles, il vous faudra ne pas remplir de valeur ou la mettre à "null". Supprimer une clé du dictionnaire fera faire une erreur à Ansible.
### 2eme étape : Installation des applications Yunohost redirect
Si vous voulez intégrer des applications conteneurisées à l'interface utilisateur YunoHost ou facilement gérer une redirection à l'aide de Nginx, il existe [l'application YunoHost redirect](https://github.com/YunoHost-Apps/redirect_ynh/).
```yml
ynh_apps:
- label: "Redirection de l'application ara"
link: "redirect"
args:
domain: "ara.exemple.com"
path: "/"
redirect_path: "http://0.0.0.0:8000"
redirect_type: "public_proxy"
```
Dans l'exemple ci-dessus. On va rediriger l'application disponible sur le port 8000 de la machine pour qu'il soit exposé sur internet depuis l'url "ara.exemple.com".
- `redirect_type` : Il existe 4 types de redirections gérées par Nginx. [Pour en savoir plus](https://github.com/YunoHost-Apps/redirect_ynh/blob/62718ad5c42705c92752908f3e062d086b87a251/manifest.json#L57).
## Dépendances
Aucune.
......
......@@ -70,6 +70,54 @@ 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.
### Docker container management
By default, YunoHost applications are pre-packaged by community members. We decided to go further, by simply adding the ability to deploy Docker containers using Docker Compose and integrate them into the YunoHost application panel.
### Step 1: Install and launch Docker containers
```yml
enable_ynh_docker: true
geerlingguy_docker_version: 5.2.1
docker_compose_src_template: templates/compose.yml.j2
docker_compose_dest_template: /tmp/compose.yml
docker_compose_version: 3.9
docker_compose_apps:
- name: app1
image: "recordsansible/ara-api:latest"
ports:
- "8000:8000"
volumes:
- "/home/{{ ynh_admin }}/.ara/server:/opt/ara"
environment: null
```
- `enable_ynh_docker`: Enables / disables the feature to install and launch Docker Compose services.
- `geerlingguy_docker_version`: Allows you to specify the version of the Ansible Docker role you wish to use. The default version of the role is 5.2.1, but you can check the role versions [here](https://github.com/geerlingguy/ansible-role-docker/tags).
- `docker_compose_src_template`: Path where the Docker Compose template file is located. By default a template file is provided by us but you can also provide your custom Docker Compose file.
- docker_compose_dest_template`: Path where the Docker Compose file will be on the remote machine.
- docker_compose_version`: Version of Docker Compose used for the file.
- docker_compose_apps`: Dictionaries of one or more Docker Compose services. In each dictionary you will be able to define: name (required), image (required), ports (optional), volumes (optional) and environment (optional, environment variables). If you don't define one of the optional keys, you will have to leave the value blank or set it to "null". Removing a key from the dictionary will make Ansible make an error.
### Step 2: Installing Yunohost redirect applications
If you want to integrate containerized applications with the YunoHost UI or easily manage a redirect using Nginx, there is [the YunoHost redirect application](https://github.com/YunoHost-Apps/redirect_ynh/).
```yml
ynh_apps:
- label: "ara application redirect"
link: "redirect"
args:
domain: "ara.example.com"
path: "/"
redirect_path: "http://0.0.0.0:8000"
redirect_type: "public_proxy"
```
In the example above. We will redirect the application available on port 8000 of the machine to be exposed on the internet from the url "ara.example.com".
- `redirect_type` : There are 4 types of redirects managed by Nginx. [For more information](https://github.com/YunoHost-Apps/redirect_ynh/blob/62718ad5c42705c92752908f3e062d086b87a251/manifest.json#L57).
## Dependencies
None.
......
......@@ -17,7 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
# The list of Yunohost apps.
ynh_apps: null
# - label: Tiny Tiny RSS
......@@ -31,3 +30,27 @@ ynh_apps: null
# type: script
# owner: ttrss # Only provide if different from app name
# group: ttrss # Only provide if different from www-data
# Variables for Docker
enable_ynh_docker: false
geerlingguy_docker_version: 5.2.1
# Variables for Docker Compose
docker_compose_src_template: templates/compose.yml.j2
# docker_compose_dest_template: /tmp/compose.yml
# docker_compose_version: 3.9
# docker_compose_apps:
# - name: app1
# image: "recordsansible/ara-api:latest"
# ports:
# - "8000:8000"
# volumes:
# - "/home/{{ ynh_admin }}/.ara/server:/opt/ara"
# environment:
# - DEBUG=1
# - name: app2
# image: "alpine:latest"
# ports: null
# volumes: null
# environment: null
......@@ -23,7 +23,7 @@
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
changed_when: false
tags: apps
# Post-installation part
......@@ -34,7 +34,7 @@
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([]) }}"
loop: "{{ ynh_app.post_install | default([]) }}"
when: ynh_app.post_install
tags: apps
......@@ -42,7 +42,7 @@
ansible.builtin.command: "{{ ynh_app_post_install.dest }}"
args:
chdir: /tmp/
loop: "{{ ynh_app.post_install|default([]) }}"
loop: "{{ ynh_app.post_install | default([]) }}"
loop_control:
loop_var: ynh_app_post_install
when: ynh_app_post_install.type == "script"
......@@ -52,7 +52,7 @@
ansible.builtin.file:
path: "{{ ynh_app_post_install.dest }}"
state: absent
loop: "{{ ynh_app.post_install|default([]) }}"
loop: "{{ ynh_app.post_install | default([]) }}"
loop_control:
loop_var: ynh_app_post_install
when: ynh_app_post_install.type == "script"
......
......@@ -17,11 +17,10 @@
# 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
changed_when: false
tags: apps
- name: Format json of apps
......
---
#-----------------------------------------------------------------------------#
# ansible-yunohost allows to deploy Yunohost using Ansible #
# Copyright 2021-present 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: Download Docker setup role on localhost
ansible.builtin.command: "ansible-galaxy install geerlingguy.docker,{{ geerlingguy_docker_version }} -p {{ _ansible_role_directory }}"
delegate_to: localhost
become: false
changed_when: false
tags: docker
- name: Gather facts for Docker role
ansible.builtin.setup:
tags: docker
- name: Install Docker and Docker Compose
ansible.builtin.import_role:
name: geerlingguy.docker
tags: docker
- name: Copy Docker Compose file
ansible.builtin.template:
src: "{{ docker_compose_src_template }}"
dest: "{{ docker_compose_dest_template }}"
mode: 0644
tags: docker
- name: Run Docker Compose file
community.docker.docker_compose:
project_src: "{{ docker_compose_dest_template }}"
state: present
tags: docker
......@@ -17,8 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#-----------------------------------------------------------------------------#
- name: Install Yunohost apps
ansible.builtin.include_tasks: apps.yml
when: ynh_apps
tags: apps
- name: Install Docker and redirect apps
ansible.builtin.include_tasks: docker.yml
when: enable_ynh_docker
tags: docker
version: "{{ docker_compose_version }}"
services:
{% for app in docker_compose_apps %}
{{ app.name }}:
image: "{{ app.image }}"
{% if app.ports %}
ports:
{% for port in app.ports %}
- "{{ port }}"
{% endfor %}
{% endif %}
{% if app.volumes %}
volumes:
{% for volume in app.volumes %}
- {{ volume }}
{% endfor %}
{% endif %}
{% if app.environment %}
environment:
{% for var in app.environment %}
- {{ var }}
{% endfor %}
{% endif %}
{% endfor %}
......@@ -42,7 +42,7 @@
ansible.builtin.file:
path: "{{ borg_repository }}"
state: directory
mode: '0750'
mode: "0750"
tags:
- backup
- borg
......@@ -54,19 +54,19 @@
block:
- name: deploy ssh public key for BorgBackup
ansible.builtin.copy:
src: "{{ borg_ssh_keys_src }}.pub"
dest: "{{ borg_ssh_keys_dest }}.pub"
src: "{{ borg_ssh_keys_src }}.pub"
dest: "{{ borg_ssh_keys_dest }}.pub"
owner: "root"
group: "root"
mode: 0600
mode: 0600
- name: deploy ssh private key for BorgBackup
ansible.builtin.copy:
src: "{{ borg_ssh_keys_src }}.vault"
dest: "{{ borg_ssh_keys_dest }}"
src: "{{ borg_ssh_keys_src }}.vault"
dest: "{{ borg_ssh_keys_dest }}"
owner: "root"
group: "root"
mode: 0600
mode: 0600
when: ynh_borg_backup_remote_repo
- name: change SSH command in "/etc/borgmatic/{{ borgmatic_config_name }}"
......@@ -80,10 +80,9 @@
- backup
- borg
- name: change archive name in "/etc/borgmatic/{{ borgmatic_config_name }}"
ansible.builtin.lineinfile:
path: "/etc/borgmatic/{{ borgmatic_config_name }}"
path: "/etc/borgmatic/{{ borgmatic_config_name }}"
regexp: "archive_name_format:"
line: " archive_name_format: {{ borg_archive_name_format }}"
state: present
......@@ -97,7 +96,7 @@
#!/bin/bash
. /opt/borgmatic/bin/activate
borg "$@"
dest: /usr/local/bin/borg
dest: /usr/local/bin/borg
owner: root
group: root
mode: "0755"
......