diff --git a/roles/ynh_apps/defaults/main.yml b/roles/ynh_apps/defaults/main.yml index 6b023b25b5c51f8f685e8a88d3bd7c3f6594dca7..d064060a2a73ef6d7edaf30d43c33a992a1bd118 100644 --- a/roles/ynh_apps/defaults/main.yml +++ b/roles/ynh_apps/defaults/main.yml @@ -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 diff --git a/roles/ynh_apps/tasks/docker.yml b/roles/ynh_apps/tasks/docker.yml new file mode 100644 index 0000000000000000000000000000000000000000..950ff2e8f581c8a49ec04767546866e6af977fb3 --- /dev/null +++ b/roles/ynh_apps/tasks/docker.yml @@ -0,0 +1,47 @@ +--- +#-----------------------------------------------------------------------------# +# 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 diff --git a/roles/ynh_apps/tasks/main.yml b/roles/ynh_apps/tasks/main.yml index 0b1181503e39a76bde7d7c4c39da5a5d92a79149..431966627273d249969b7fccc5811dc0f78fce9f 100644 --- a/roles/ynh_apps/tasks/main.yml +++ b/roles/ynh_apps/tasks/main.yml @@ -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