Add native Traefik support to Sygnal

This commit is contained in:
Slavi Pantaleev
2023-02-26 11:03:42 +02:00
parent eb213c1195
commit d20ff688db
11 changed files with 206 additions and 43 deletions

View File

@ -1,16 +1,5 @@
---
- name: Ensure Sygnal image is pulled
community.docker.docker_image:
name: "{{ matrix_sygnal_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_sygnal_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_sygnal_docker_image_force_pull }}"
register: result
retries: "{{ devture_playbook_help_container_retries_count }}"
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed
- name: Ensure Sygnal paths exists
ansible.builtin.file:
path: "{{ item }}"
@ -31,6 +20,30 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure Sygnal labels installed
ansible.builtin.template:
src: "{{ role_path }}/templates/labels.j2"
dest: "{{ matrix_sygnal_base_path }}/labels"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure Sygnal image is pulled
community.docker.docker_image:
name: "{{ matrix_sygnal_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_sygnal_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_sygnal_docker_image_force_pull }}"
register: result
retries: "{{ devture_playbook_help_container_retries_count }}"
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed
- name: Ensure Sygnal container network is created
community.general.docker_network:
name: "{{ matrix_sygnal_container_network }}"
driver: bridge
- name: Ensure matrix-sygnal.service installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-sygnal.service.j2"

View File

@ -5,7 +5,7 @@
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
- when: matrix_sygnal_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml"
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
tags:
- setup-all
- setup-sygnal
@ -14,7 +14,7 @@
- block:
- when: not matrix_sygnal_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
ansible.builtin.include_tasks: "{{ role_path }}/tasks/uninstall.yml"
tags:
- setup-all
- setup-sygnal

View File

@ -1,7 +1,37 @@
---
- name: Fail if required Sygnal settings not defined
ansible.builtin.fail:
msg: >
You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''"
with_items:
- matrix_sygnal_hostname
- matrix_sygnal_path_prefix
- matrix_sygnal_container_network
- when: matrix_sygnal_container_labels_traefik_enabled | bool
block:
- name: Fail if required Sygnal Traefik settings not defined
ansible.builtin.fail:
msg: >-
You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''"
with_items:
- matrix_sygnal_container_labels_traefik_hostname
- matrix_sygnal_container_labels_traefik_path_prefix
# We ensure it doesn't end with a slash, because we handle both (slash and no-slash).
# Knowing that `matrix_sygnal_container_labels_traefik_path_prefix` does not end with a slash
# ensures we know how to set these routes up without having to do "does it end with a slash" checks elsewhere.
- name: Fail if matrix_sygnal_container_labels_traefik_path_prefix ends with a slash
ansible.builtin.fail:
msg: >-
matrix_sygnal_container_labels_traefik_path_prefix (`{{ matrix_sygnal_container_labels_traefik_path_prefix }}`) must either be `/` or not end with a slash (e.g. `/sygnal`).
when: "matrix_sygnal_container_labels_traefik_path_prefix != '/' and matrix_sygnal_container_labels_traefik_path_prefix[-1] == '/'"
- name: Fail if no Sygnal apps defined
ansible.builtin.fail:
msg: >-
Enabling Sygnal requires that you specify at least one app in `matrix_sygnal_apps`
when: "matrix_sygnal_enabled and matrix_sygnal_apps | length == 0"
when: "matrix_sygnal_apps | length == 0"