add FluffyChat (#4068)
* add FluffyChat * capitalization * Update group_vars/matrix_servers Co-authored-by: Slavi Pantaleev <slavi@devture.com> * fix link in readme --------- Co-authored-by: Slavi Pantaleev <slavi@devture.com>
This commit is contained in:
26
roles/custom/matrix-client-fluffychat/tasks/main.yml
Normal file
26
roles/custom/matrix-client-fluffychat/tasks/main.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-client-fluffychat
|
||||
- install-all
|
||||
- install-client-fluffychat
|
||||
block:
|
||||
- when: matrix_client_fluffychat_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
|
||||
- when: matrix_client_fluffychat_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-client-fluffychat
|
||||
block:
|
||||
- when: not matrix_client_fluffychat_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
|
||||
- tags:
|
||||
- self-check
|
||||
block:
|
||||
- when: matrix_client_fluffychat_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml"
|
24
roles/custom/matrix-client-fluffychat/tasks/self_check.yml
Normal file
24
roles/custom/matrix-client-fluffychat/tasks/self_check.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_client_fluffychat_url_endpoint_public: "{{ matrix_client_fluffychat_scheme }}://{{ matrix_client_fluffychat_hostname }}/"
|
||||
|
||||
- name: Check FluffyChat Web
|
||||
ansible.builtin.uri:
|
||||
url: "{{ matrix_client_fluffychat_url_endpoint_public }}"
|
||||
follow_redirects: none
|
||||
validate_certs: "{{ matrix_client_fluffychat_self_check_validate_certificates }}"
|
||||
register: matrix_client_fluffychat_self_check_result
|
||||
check_mode: false
|
||||
ignore_errors: true
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
|
||||
- name: Fail if FluffyChat Web not working
|
||||
ansible.builtin.fail:
|
||||
msg: "Failed checking FluffyChat Web is up at `{{ matrix_server_fqn_fluffychat }}` (checked endpoint: `{{ matrix_client_fluffychat_url_endpoint_public }}`). Is FluffyChat Web running? Is port 443 open in your firewall? Full error: {{ matrix_client_fluffychat_self_check_result }}"
|
||||
when: "matrix_client_fluffychat_self_check_result.failed or 'json' not in matrix_client_fluffychat_self_check_result"
|
||||
|
||||
- name: Report working FluffyChat Web
|
||||
ansible.builtin.debug:
|
||||
msg: "FluffyChat Web at `{{ matrix_server_fqn_fluffychat }}` is working (checked endpoint: `{{ matrix_client_fluffychat_url_endpoint_public }}`)"
|
@ -0,0 +1,70 @@
|
||||
---
|
||||
|
||||
- name: Ensure FluffyChat Web paths exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_client_fluffychat_data_path }}", when: true}
|
||||
- {path: "{{ matrix_client_fluffychat_container_src_files_path }}", when: "{{ matrix_client_fluffychat_container_image_self_build }}"}
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure FluffyChat Web container image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_client_fluffychat_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_client_fluffychat_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_client_fluffychat_docker_image_force_pull }}"
|
||||
when: "not matrix_client_fluffychat_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ devture_playbook_help_container_retries_count }}"
|
||||
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- when: "matrix_client_fluffychat_container_image_self_build | bool"
|
||||
block:
|
||||
- name: Ensure FluffyChat Web repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_client_fluffychat_container_image_self_build_repo }}"
|
||||
dest: "{{ matrix_client_fluffychat_container_src_files_path }}"
|
||||
version: "{{ matrix_client_fluffychat_container_image_self_build_version }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_client_fluffychat_git_pull_results
|
||||
|
||||
- name: Ensure FluffyChat Web container image is built
|
||||
ansible.builtin.command:
|
||||
cmd: |-
|
||||
{{ devture_systemd_docker_base_host_command_docker }} buildx build
|
||||
--tag={{ matrix_client_fluffychat_docker_image }}
|
||||
--file={{ matrix_client_fluffychat_container_src_files_path }}/Dockerfile
|
||||
{{ matrix_client_fluffychat_container_src_files_path }}
|
||||
changed_when: true
|
||||
|
||||
- name: Ensure FluffyChat Web config files installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ matrix_client_fluffychat_data_path }}/{{ item.name }}"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
|
||||
when: "item.src is not none"
|
||||
|
||||
- name: Ensure FluffyChat Web container network is created
|
||||
community.general.docker_network:
|
||||
enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
|
||||
name: "{{ matrix_client_fluffychat_container_network }}"
|
||||
driver: bridge
|
||||
driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
|
||||
|
||||
- name: Ensure matrix-client-fluffychat.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-client-fluffychat.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-fluffychat.service"
|
||||
mode: 0644
|
@ -0,0 +1,25 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-client-fluffychat.service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-fluffychat.service"
|
||||
register: matrix_client_fluffychat_service_stat
|
||||
|
||||
- when: matrix_client_fluffychat_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-client-fluffychat is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-client-fluffychat
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-client-fluffychat.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-fluffychat.service"
|
||||
state: absent
|
||||
|
||||
- name: Ensure FluffyChat Web path doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_client_fluffychat_data_path }}"
|
||||
state: absent
|
@ -0,0 +1,29 @@
|
||||
---
|
||||
|
||||
- name: Fail if required FluffyChat Web settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >
|
||||
You need to define a required configuration setting (`{{ item }}`) for using FluffyChat Web.
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_client_fluffychat_container_network
|
||||
|
||||
- when: matrix_client_fluffychat_container_labels_traefik_enabled | bool
|
||||
block:
|
||||
- name: Fail if required matrix-client-fluffychat Traefik settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_client_fluffychat_container_labels_traefik_hostname
|
||||
- matrix_client_fluffychat_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_client_fluffychat_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_client_fluffychat_container_labels_traefik_path_prefix ends with a slash
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
matrix_client_fluffychat_container_labels_traefik_path_prefix (`{{ matrix_client_fluffychat_container_labels_traefik_path_prefix }}`) must either be `/` or not end with a slash (e.g. `/fluffychat`).
|
||||
when: "matrix_client_fluffychat_container_labels_traefik_path_prefix != '/' and matrix_client_fluffychat_container_labels_traefik_path_prefix[-1] == '/'"
|
Reference in New Issue
Block a user