Add initial templates for docker-compose services (gitea, nextcloud, traefik)
This commit is contained in:
33
roles/traefik/tasks/main.yml
Normal file
33
roles/traefik/tasks/main.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
# https://stackoverflow.com/questions/41667864/can-the-templates-module-handle-multiple-templates-directories
|
||||
|
||||
- name: Ensure service directory exists
|
||||
file:
|
||||
path: "{{ current_svc_path }}"
|
||||
state: directory
|
||||
mode: "500"
|
||||
|
||||
- name: Ensure directory structure exists
|
||||
file:
|
||||
path: "{{ current_svc_path }}/{{ item.path }}"
|
||||
state: directory
|
||||
mode: "500"
|
||||
with_community.general.filetree: "{{ templates_source }}"
|
||||
when: item.state == "directory"
|
||||
|
||||
|
||||
#- name: Include app config variables
|
||||
# include_vars:
|
||||
# file: "{{ role_path }}/vars/app_config.yml"
|
||||
|
||||
- name: Generate {{ current_svc_name }} deployment from templates
|
||||
template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ current_svc_path }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
mode: "400"
|
||||
with_community.general.filetree: "{{ templates_source }}"
|
||||
when: item.state == "file"
|
||||
|
||||
- name: Deploy docker-compose for {{ current_svc_name }}
|
||||
community.docker.docker_compose:
|
||||
project_src: "{{ current_svc_path }}"
|
||||
state: present
|
0
roles/traefik/templates/.env.traefik.j2
Normal file
0
roles/traefik/templates/.env.traefik.j2
Normal file
20
roles/traefik/templates/docker-compose.yml.j2
Normal file
20
roles/traefik/templates/docker-compose.yml.j2
Normal file
@@ -0,0 +1,20 @@
|
||||
version: "3.9"
|
||||
|
||||
networks:
|
||||
traefik:
|
||||
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:v2.8
|
||||
container_name: traefik
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- .env.traefik
|
||||
networks:
|
||||
- traefik
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./traefik.yml:/etc/traefik/traefik.yml:ro
|
7
roles/traefik/templates/traefik.yml.j2
Normal file
7
roles/traefik/templates/traefik.yml.j2
Normal file
@@ -0,0 +1,7 @@
|
||||
api:
|
||||
insecure: true
|
||||
|
||||
providers:
|
||||
docker:
|
||||
exposedByDefault: false
|
||||
network: traefik_traefik
|
0
roles/traefik/vars/app_config.yml
Normal file
0
roles/traefik/vars/app_config.yml
Normal file
5
roles/traefik/vars/main.yml
Normal file
5
roles/traefik/vars/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
current_svc_name: traefik
|
||||
current_svc_path: "{{ my_svc_path }}/{{ current_svc_name }}"
|
||||
|
||||
templates_source: "{{ role_path }}/templates"
|
Reference in New Issue
Block a user