diff --git a/playbooks/matrix_webhooks.yml b/playbooks/matrix_webhooks.yml deleted file mode 100644 index f7f4ca2..0000000 --- a/playbooks/matrix_webhooks.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# Infrastructure -# Ansible instructions to deploy the infrastructure -# Copyright (C) 2021 Saibotk -# -# 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, version 3 of the License. -# -# 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 . - -- name: Install & configure Matrix Webhooks - hosts: matrix_webhooks - roles: - - docker - - docker_cleanup - - traefik - - matrix_webhooks diff --git a/roles/matrix_webhooks/README.md b/roles/matrix_webhooks/README.md deleted file mode 100644 index 6822137..0000000 --- a/roles/matrix_webhooks/README.md +++ /dev/null @@ -1,37 +0,0 @@ -Matrix-Webhooks -========= - -This will setup a [Matrix-Webhooks-appservice](https://github.com/turt2live/matrix-appservice-webhooks) instance using the official docker container and traefik as a reverse proxy. - -Requirements ------------- - -You will need to have docker, docker-compose and traefik installed or declared as dependencies with their respective roles. - -**This role assumes that you have setup traefik with an endpoint called `websecure`.** - -**You will also need to manually copy the appservice's registration file to your homeserver's directory and enable it in the config for this appservice to work!** - -Role Variables --------------- - -**Please look at the [defaults/main.yml](defaults/main.yml) for all available variables and their description.** - -**Note: Lines that are commented out via `#` are usually still valid/used variables, but they are not defined by default, so they might enable a feature, when uncommenting/defining them!** - -### Global variables, that are used: - -- `proxy_network`: Defined by the local traefik installation, this is the shared proxy network used by traefik to reach the containers. (optional) -- `proxy_hiddenservice`: Defined by the local traefik installation, this is used to generate the alt-svc header for the alternative Tor domain. (optional) - -Dependencies ------------- - -- docker -- docker-compose -- traefik - -License -------- - -GPL-3.0-only diff --git a/roles/matrix_webhooks/defaults/main.yml b/roles/matrix_webhooks/defaults/main.yml deleted file mode 100644 index ed5ab8e..0000000 --- a/roles/matrix_webhooks/defaults/main.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -# Default variables for the matrix-webhooks role - -# Infrastructure -# Ansible instructions to deploy the infrastructure -# Copyright (C) 2021 Saibotk -# -# 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, version 3 of the License. -# -# 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 . -# - -# The install location -matrix_webhooks_install_location: /srv/matrix-webhooks - -# The location to store webhook related data in -matrix_webhooks_data_location: "{{ matrix_webhooks_install_location }}/data" - -# Under which domain should the service be reachable via traefik -matrix_webhooks_domain: "webhooks.example.com" - -# The certresolver that is used by traefik for this domain -matrix_webhooks_traefik_certresolver: letsencrypt_http - -# The URL to the Client->Server API of the corresponding homeserver -matrix_webhooks_hs_api_url: "https://matrix.example.com" - -# The domain part/right hand side of the MXID that this bot should run under (example: matrix.org) -matrix_webhooks_hs_servername: "example.com" - -# Container versions -# renovate: depName=docker.io/turt2live/matrix-appservice-webhooks -matrix_webhooks_image_version: "latest" - -# The Provision API key -matrix_webhooks_provisioning_key: "{{ lookup('passwordstore', matrix_webhooks_domain + '/provisioning-api create=true length=42') }}" - -# Webhook user profile (seems to be unused at the moment) -matrix_webhooks_display_name: "Captain Webhook" -matrix_webhooks_avatar: "http://i.imgur.com/IDOBtEJ.png" diff --git a/roles/matrix_webhooks/handlers/main.yml b/roles/matrix_webhooks/handlers/main.yml deleted file mode 100644 index 6eba2ea..0000000 --- a/roles/matrix_webhooks/handlers/main.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -# Handlers file for the matrix-webhooks role - -# Infrastructure -# Ansible instructions to deploy the infrastructure -# Copyright (C) 2021 Saibotk -# -# 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, version 3 of the License. -# -# 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 . -# - -- name: Restart matrix webhooks - community.docker.docker_compose_v2: - services: - - appservice-webhooks - state: restarted - project_src: "{{ matrix_webhooks_install_location }}" - tags: - - docker - - matrix - - webhooks - become: true diff --git a/roles/matrix_webhooks/meta/main.yml b/roles/matrix_webhooks/meta/main.yml deleted file mode 100644 index 8d77833..0000000 --- a/roles/matrix_webhooks/meta/main.yml +++ /dev/null @@ -1,44 +0,0 @@ -galaxy_info: - author: saibotk - description: "Deploys a matrix webhook appservice server via docker using traefik." - license: GPL-3.0-only - min_ansible_version: "2.9" - standalone: true - - platforms: - - name: EL - versions: - - all - - name: GenericUNIX - versions: - - all - - name: Fedora - versions: - - all - - name: opensuse - versions: - - all - - name: GenericBSD - versions: - - all - - name: FreeBSD - versions: - - all - - name: Ubuntu - versions: - - all - - name: SLES - versions: - - all - - name: GenericLinux - versions: - - all - - name: Debian - versions: - - all - - galaxy_tags: [] - -dependencies: - - role: docker - - role: traefik diff --git a/roles/matrix_webhooks/tasks/main.yml b/roles/matrix_webhooks/tasks/main.yml deleted file mode 100644 index 17e734f..0000000 --- a/roles/matrix_webhooks/tasks/main.yml +++ /dev/null @@ -1,102 +0,0 @@ ---- -# Tasks file for the matrix-webhooks role - -# Infrastructure -# Ansible instructions to deploy the infrastructure -# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern -# Copyright (C) 2019-2020 Alexander (w4tsn) Wellbrock -# Copyright (C) 2020-2021 Saibotk -# -# 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, version 3 of the License. -# -# 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 . -# - -- name: Update default SELinux contexts - community.general.sefcontext: - target: "{{ item }}(/.*)?" - setype: "container_file_t" - state: present - with_items: - - "{{ matrix_webhooks_data_location }}" - become: true - -- name: Create install directory - ansible.builtin.file: - path: "{{ item }}" - state: directory - mode: "0700" - owner: "root" - group: "root" - with_items: - - "{{ matrix_webhooks_install_location }}" - become: true - -- name: Create data directory - ansible.builtin.file: # noqa risky-file-permissions # Container manages permissions on its own - path: "{{ item }}" - state: directory - setype: "container_file_t" - with_items: - - "{{ matrix_webhooks_data_location }}" - become: true - -- name: Deploy docker-compose.yml - ansible.builtin.template: - src: "docker-compose.yml" - dest: "{{ matrix_webhooks_install_location }}/docker-compose.yml" - mode: "0600" - owner: "root" - group: "root" - validate: docker compose -f %s config -q - tags: - - matrix - - webhooks - become: true - -- name: Deploy webhooks config files - ansible.builtin.template: - src: "{{ item }}" - dest: "{{ matrix_webhooks_data_location }}/{{ item }}" - setype: "container_file_t" - mode: "0640" - owner: "root" - group: "root" - with_items: - - "database.json" - - "config.yaml" - tags: - - docker - - matrix - - webhooks - notify: Restart matrix webhooks - become: true - -- name: Generate webhooks registration - ansible.builtin.command: - cmd: 'docker-compose run appservice-webhooks node index.js -r \ - -f /data/appservice-registration-webhooks.yaml \ - -u "https://{{ matrix_webhooks_domain }}" -c /data/config.yaml' - chdir: "{{ matrix_webhooks_install_location }}" - creates: "{{ matrix_webhooks_data_location }}/appservice-registration-webhooks.yaml" - become: true - -- name: Compose matrix-webhooks - community.docker.docker_compose_v2: - state: present - project_src: "{{ matrix_webhooks_install_location }}" - pull: always - remove_orphans: true - tags: - - docker - - matrix - - webhooks - become: true diff --git a/roles/matrix_webhooks/templates/config.yaml b/roles/matrix_webhooks/templates/config.yaml deleted file mode 100644 index 5594414..0000000 --- a/roles/matrix_webhooks/templates/config.yaml +++ /dev/null @@ -1,39 +0,0 @@ -{{ ansible_managed | comment }} - -# Configuration specific to the application service. All fields (unless otherwise marked) are required. -homeserver: - # The domain for the client-server API calls. - url: "{{ matrix_webhooks_hs_api_url }}" - - # The domain part for user IDs on this home server. Usually, but not always, this is the same as the - # home server's URL. - domain: "{{ matrix_webhooks_hs_servername }}" - -# Configuration specific to the bridge. All fields (unless otherwise marked) are required. -webhookBot: - # The localpart to use for the bot. May require re-registering the application service. - localpart: "_webhook" - - # Appearance options for the Matrix bot - appearance: - displayName: "{{ matrix_webhooks_display_name }}" - avatarUrl: "{{ matrix_webhooks_avatar }}" # webhook icon - -# Provisioning API options -provisioning: - # Your secret for the API. Required for all provisioning API requests. - secret: '{{ matrix_webhooks_provisioning_key }}' - -# Configuration related to the web portion of the bridge. Handles the inbound webhooks -web: - hookUrlBase: 'https://{{ matrix_webhooks_domain }}/' - -logging: - file: data/logs/webhook.log - console: true - consoleLevel: info - fileLevel: verbose - writeFiles: true - rotate: - size: 52428800 # bytes, default is 50mb - count: 5 diff --git a/roles/matrix_webhooks/templates/database.json b/roles/matrix_webhooks/templates/database.json deleted file mode 100644 index f1d3573..0000000 --- a/roles/matrix_webhooks/templates/database.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "defaultEnv": { - "ENV": "NODE_ENV" - }, - "development": { - "driver": "sqlite3", - "filename": "data/development.db" - }, - "production": { - "driver": "sqlite3", - "filename": "data/production.db" - } -} diff --git a/roles/matrix_webhooks/templates/docker-compose.yml b/roles/matrix_webhooks/templates/docker-compose.yml deleted file mode 100644 index 5b63e71..0000000 --- a/roles/matrix_webhooks/templates/docker-compose.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -# Infrastructure -# Ansible instructions to deploy the infrastructure -# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern -# Copyright (C) 2019-2020 Alexander (w4tsn) Wellbrock -# Copyright (C) 2020 Saibotk -# -# 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, version 3 of the License. -# -# 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 . -# - -version: '2' -services: - appservice-webhooks: - image: docker.io/turt2live/matrix-appservice-webhooks:{{ matrix_webhooks_image_version }} - mem_limit: 128mb - memswap_limit: 256mb - read_only: true - security_opt: - - no-new-privileges - volumes: - - "{{ matrix_webhooks_data_location }}:/data" - labels: - - "traefik.enable=true" - - - "traefik.http.routers.matrix-webhooks.rule=Host(`{{ matrix_webhooks_domain }}`) && PathPrefix(`/`)" - - "traefik.http.routers.matrix-webhooks.entrypoints=websecure" - - "traefik.http.routers.matrix-webhooks.tls.certresolver={{ matrix_webhooks_traefik_certresolver }}" - - "traefik.http.routers.matrix-webhooks.middlewares=matrix-webhooks,compress" - - "traefik.http.services.matrix-webhooks.loadbalancer.server.port=9000" - - "traefik.http.middlewares.matrix-webhooks.headers.sslredirect=true" - - "traefik.http.middlewares.matrix-webhooks.headers.stsSeconds=63072000" - - "traefik.http.middlewares.matrix-webhooks.headers.referrerPolicy=no-referrer" - -{% if proxy_network is defined %} - - "traefik.docker.network={{ proxy_network }}" -{% endif %} -{% if proxy_hiddenservice is defined and proxy_hiddenservice.content is defined %} - - "traefik.http.middlewares.matrix-webhooks.headers.customresponseheaders.alt-svc:h2={{ proxy_hiddenservice['content'] | b64decode | trim }}:443; ma=2592000" -{% endif %} -{% if proxy_network is defined %} - networks: - {{ proxy_network }}: -{% endif %} - restart: always - -{% if proxy_network is defined %} -networks: - {{ proxy_network }}: - external: true -{% endif %}