mirror of
https://github.com/status-im/infra-role-matterbridge.git
synced 2025-02-20 02:28:15 +00:00
add matterbridge ansible role
Signed-off-by: Arthur Koziel <arthur@arthurkoziel.com>
This commit is contained in:
commit
1a137e6a04
42
README.md
Normal file
42
README.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Description
|
||||
|
||||
This role configures [`matterbridge`](https://github.com/42wim/matterbridge) chat bridging software.
|
||||
|
||||
# Details
|
||||
|
||||
The software runs as a docker container from [`42wim/matterbridge`](https://hub.docker.com/r/42wim/matterbridge/).
|
||||
|
||||
The configuration file template is in [`templates/matterbridge.yaml.j2`](./templates/matterbridge.yaml.j2).
|
||||
|
||||
# Configuration
|
||||
|
||||
```yaml
|
||||
matterbridge_bridges:
|
||||
status:
|
||||
bridge:
|
||||
Nick: 'bridge.stateofus.eth'
|
||||
PrivateKey: '0x04abcXYZ'
|
||||
RemoteNickFormat: '**{NICK}**@*{PROTOCOL}*: '
|
||||
|
||||
discord:
|
||||
status-pub:
|
||||
Token: 'super-secret-token'
|
||||
Server: 'Status Community'
|
||||
RemoteNickFormat: '{NICK}@{PROTOCOL}'
|
||||
|
||||
matterbridge_gateways:
|
||||
- { status: "tech", discord: [{ srv: "status-pub", ch: "tech" }] }
|
||||
- { status: "music", discord: [{ srv: "status-pub", ch: "music" }] }
|
||||
- { status: "movies", discord: [{ srv: "status-pub", ch: "movies" }] }
|
||||
```
|
||||
|
||||
# Known Issues
|
||||
|
||||
If your bridge is posting in a Discord channel but doesn't receive mesages from it you might have to adjust the channel-level permissions to give the bot message read rights.
|
||||
|
||||
# Links
|
||||
|
||||
* https://github.com/42wim/matterbridge/blob/master/matterbridge.toml.sample
|
||||
* https://github.com/42wim/matterbridge/wiki/How-to-create-your-config
|
||||
* https://github.com/42wim/matterbridge/wiki/Settings
|
||||
* https://notes.status.im/s/slack-bridge-bot-setup
|
16
defaults/main.yml
Normal file
16
defaults/main.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
matterbridge_version: 'latest'
|
||||
matterbridge_cont_image: 'statusteam/matterbridge:{{ matterbridge_version }}'
|
||||
matterbridge_cont_name: 'matterbridge'
|
||||
matterbridge_cont_vol: '/docker/{{ matterbridge_cont_name }}'
|
||||
matterbridge_debug: false
|
||||
matterbridge_nick: bridge
|
||||
matterbridge_ens_name: bridge.stateofus.eth
|
||||
|
||||
# configuration for gateways
|
||||
matterbridge_gateways: []
|
||||
|
||||
# general container management
|
||||
cont_state: started
|
||||
cont_recreate: false
|
||||
cont_restart: false
|
16
tasks/config.yml
Normal file
16
tasks/config.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: MatterBridge | Create container directory
|
||||
file:
|
||||
path: '{{ matterbridge_cont_vol }}'
|
||||
state: directory
|
||||
owner: dockremap
|
||||
group: docker
|
||||
recurse: true
|
||||
|
||||
- name: MatterBridge | Generate YAML configuration
|
||||
template:
|
||||
src: 'matterbridge.yaml.j2'
|
||||
dest: '{{ matterbridge_cont_vol }}/matterbridge.yaml'
|
||||
owner: dockremap
|
||||
group: docker
|
||||
register: config_file
|
13
tasks/consul.yml
Normal file
13
tasks/consul.yml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Create Consul service definition
|
||||
include_role: name=consul-service
|
||||
vars:
|
||||
consul_config_name: '{{ matterbridge_cont_name }}'
|
||||
consul_services:
|
||||
- name: '{{ matterbridge_cont_name }}'
|
||||
tags: ['matterbridge', 'bridge']
|
||||
checks:
|
||||
- id: '{{ matterbridge_cont_name }}-status'
|
||||
name: 'MatterBridge health'
|
||||
type: 'script'
|
||||
script: '/usr/bin/pgrep -xl matterbridge'
|
15
tasks/container.yml
Normal file
15
tasks/container.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: MatterBridge | Create container
|
||||
docker_container:
|
||||
name: '{{ matterbridge_cont_name }}'
|
||||
image: '{{ matterbridge_cont_image }}'
|
||||
pull: true
|
||||
restart_policy: always
|
||||
state: '{{ cont_state }}'
|
||||
recreate: '{{ cont_recreate }}'
|
||||
restart: '{{ config_file.changed or cont_restart }}'
|
||||
volumes:
|
||||
- '{{ matterbridge_cont_vol }}/matterbridge.yaml:/matterbridge.yaml'
|
||||
command: |
|
||||
-conf=/matterbridge.yaml
|
||||
{% if matterbridge_debug %}-debug{% endif %}
|
4
tasks/main.yml
Normal file
4
tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
- import_tasks: config.yml
|
||||
- import_tasks: container.yml
|
||||
- import_tasks: consul.yml
|
58
templates/matterbridge.yaml.j2
Normal file
58
templates/matterbridge.yaml.j2
Normal file
@ -0,0 +1,58 @@
|
||||
---
|
||||
Nick: "autobot"
|
||||
|
||||
general:
|
||||
RemoteNickFormat: "[{PROTOCOL}/{BRIDGE}] <{NICK}> "
|
||||
|
||||
########################################
|
||||
# Definition of bridges to be used #
|
||||
########################################
|
||||
|
||||
{{ matterbridge_bridges | to_nice_yaml }}
|
||||
|
||||
#######################################
|
||||
# These are auto generated by Ansible #
|
||||
#######################################
|
||||
|
||||
gateway:
|
||||
{% for gtw in matterbridge_gateways %}
|
||||
- name: "{{ gtw.status | default('bridge#'+(loop.index|string)) | mandatory }}"
|
||||
enable: "true"
|
||||
inout:
|
||||
{% if gtw.get("status", false) and not gtw.get("private", false) %}
|
||||
|
||||
- account: "status.bridge"
|
||||
channel: "{{ gtw.status }}"
|
||||
{% endif %}
|
||||
{% if gtw.get("gitter", false) %}
|
||||
|
||||
- account: "gitter.autobot"
|
||||
channel: "{{ gtw.gitter }}"
|
||||
{% endif %}
|
||||
{% if gtw.get("telegram", false) %}
|
||||
|
||||
- account: "telegram.autobot"
|
||||
channel: "{{ gtw.telegram }}"
|
||||
{% endif %}
|
||||
{% for slack_srv in gtw.get("slack", []) %}
|
||||
|
||||
- account: "slack.{{ slack_srv.srv }}"
|
||||
channel: "{{ slack_srv.ch }}"
|
||||
{% endfor %}
|
||||
{% for discord_srv in gtw.get("discord", []) %}
|
||||
|
||||
- account: "discord.{{ discord_srv.srv }}"
|
||||
channel: "{{ discord_srv.ch }}"
|
||||
options:
|
||||
WebhookURL: "{{lookup("passwordstore", "cloud/Discord/webhooks/"+discord_srv.srv+"/"+discord_srv.ch)}}"
|
||||
{% endfor %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% if matterbridge_extra is defined %}
|
||||
########################################
|
||||
# special cases for bridging #
|
||||
########################################
|
||||
|
||||
{{ matterbridge_extra | to_nice_yaml(indent=2) | trim | indent(2) }}
|
||||
{% endif %}
|
Loading…
x
Reference in New Issue
Block a user