mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-06-25 18:57:50 +02:00
optional role for matrix-fluffygate
This commit is contained in:
62
roles/custom/matrix-fluffygate/tasks/install.yml
Normal file
62
roles/custom/matrix-fluffygate/tasks/install.yml
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
|
||||
- name: Ensure Fluffygate paths exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- "{{ matrix_fluffygate_base_path }}"
|
||||
- "{{ matrix_fluffygate_config_path }}"
|
||||
- "{{ matrix_fluffygate_data_path }}"
|
||||
|
||||
- name: Ensure Fluffygate config installed
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_fluffygate_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_fluffygate_config_path }}/config.yaml"
|
||||
mode: 0640
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure Firebase key file is created when enabled
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_fluffygate_firebase_key }}"
|
||||
dest: "{{ matrix_fluffygate_data_path }}/firebase-key.json"
|
||||
mode: 0600
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
when: matrix_fluffygate_firebase_key != ''
|
||||
|
||||
- name: Ensure Fluffygate labels installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/labels.j2"
|
||||
dest: "{{ matrix_fluffygate_base_path }}/labels"
|
||||
mode: 0640
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure Fluffygate image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_fluffygate_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_fluffygate_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_fluffygate_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 Fluffygate container network is created
|
||||
community.general.docker_network:
|
||||
enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
|
||||
name: "{{ matrix_fluffygate_container_network }}"
|
||||
driver: bridge
|
||||
driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
|
||||
|
||||
- name: Ensure matrix-fluffygate.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-fluffygate.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-fluffygate.service"
|
||||
mode: 0644
|
20
roles/custom/matrix-fluffygate/tasks/main.yml
Normal file
20
roles/custom/matrix-fluffygate/tasks/main.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-fluffygate
|
||||
- install-all
|
||||
- install-fluffygate
|
||||
block:
|
||||
- when: matrix_fluffygate_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
|
||||
- when: matrix_fluffygate_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-fluffygate
|
||||
block:
|
||||
- when: not matrix_fluffygate_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/uninstall.yml"
|
25
roles/custom/matrix-fluffygate/tasks/uninstall.yml
Normal file
25
roles/custom/matrix-fluffygate/tasks/uninstall.yml
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-fluffygate service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-fluffygate.service"
|
||||
register: matrix_fluffygate_service_stat
|
||||
|
||||
- when: matrix_fluffygate_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-fluffygate is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-fluffygate
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-fluffygate.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-fluffygate.service"
|
||||
state: absent
|
||||
|
||||
- name: Ensure Fluffygate base directory doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_fluffygate_base_path }}"
|
||||
state: absent
|
40
roles/custom/matrix-fluffygate/tasks/validate_config.yml
Normal file
40
roles/custom/matrix-fluffygate/tasks/validate_config.yml
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
|
||||
- name: Fail if required Fluffygate settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_fluffygate_hostname
|
||||
- matrix_fluffygate_path_prefix
|
||||
- matrix_fluffygate_container_network
|
||||
|
||||
- when: matrix_fluffygate_container_labels_traefik_enabled | bool
|
||||
block:
|
||||
- name: Fail if required Fluffygate Traefik settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_fluffygate_container_labels_traefik_hostname
|
||||
- matrix_fluffygate_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_fluffygate_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_fluffygate_container_labels_traefik_path_prefix ends with a slash
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
matrix_fluffygate_container_labels_traefik_path_prefix (`{{ matrix_fluffygate_container_labels_traefik_path_prefix }}`) must either be `/` or not end with a slash (e.g. `/fluffygate`).
|
||||
when: "matrix_fluffygate_container_labels_traefik_path_prefix != '/' and matrix_fluffygate_container_labels_traefik_path_prefix[-1] == '/'"
|
||||
|
||||
- name: Fail if required Fluffygate settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_fluffygate_app_name
|
||||
- matrix_fluffygate_app_website
|
Reference in New Issue
Block a user