diff --git a/pillar/role/matrix.sls b/pillar/role/matrix.sls index 478500c..89017b7 100644 --- a/pillar/role/matrix.sls +++ b/pillar/role/matrix.sls @@ -26,6 +26,51 @@ profile: appservice_id: oepzkscngbyqvopzn773ns7whfxyfslgjhy7mumy7syurqp3f4kvb4sgufz9nfsw api_id: +include: + - role.common.nginx + +nginx: + ng: + servers: + managed: + chat.opensuse.org.conf: + config: + - server: + - server_name: chat.opensuse.org + - listen: + - 80 + - default_server + - root: /var/www/riot-web + - gzip_vary: 'on' + - gzip_min_length: 1000 + - gzip_comp_level: 5 + - gzip_types: + - text/plain + - text/xml text/x-js + - application/json + - text/css + - application/x-javascript + - application/javascript + - expires: $expires + - location /: + - index: + - index.html + - index.htm + - location ~* \.(?:ttf|otf|eot|woff)$: + - add_header: Access-Control-Allow-Origin "*" + - access_log: /var/log/nginx/chat.access.log combined + - error_log: /var/log/nginx/chat.error.log + - server: + - server_name: dimension.opensuse.org + - listen: + - 80 + - root: /var/www/html + - index: index.html + - location /: + - proxy_set_header X-Forwarded-For: $proxy_add_x_forwarded_for + - proxy_pass: http://localhost:8184 + enabled: True + sudoers: included_files: /etc/sudoers.d/group_matrix-admins: diff --git a/salt/profile/matrix/dimension.sls b/salt/profile/matrix/dimension.sls new file mode 100644 index 0000000..b142c72 --- /dev/null +++ b/salt/profile/matrix/dimension.sls @@ -0,0 +1,64 @@ +{% set appservices = salt['pillar.get']('profile:matrix:appservices') %} + +/var/lib/matrix-synapse/dimension: + file.directory: + - user: synapse + +https://github.com/turt2live/matrix-dimension.git: + git.latest: + - branch: master + - target: /var/lib/matrix-synapse/dimension + - rev: master + - user: synapse + +dimension_conf_file: + file.managed: + - name: /var/lib/matrix-synapse/dimension/config/production.yaml + - source: salt://profile/matrix/files/config-dimension.yaml + - template: jinja + - user: synapse + - require: + - file: /var/lib/matrix-synapse/dimension + - require_in: + - service: dimension_service + - watch_in: + - module: dimension_restart + +dimension_boostrap: + cmd.run: + - name: npm install + - cwd: /var/lib/matrix-synapse/dimension + - runas: synapse + - env: + - NODE_VERSION: 10 + +dimension_build: + cmd.run: + - name: npm run build + - cwd: /var/lib/matrix-synapse/dimension + - runas: synapse + - env: + - NODE_VERSION: 10 + +dimension_systemd_file: + file.managed: + - name: /etc/systemd/system/dimension.service + - template: jinja + - source: salt://profile/matrix/files/dimension.service + - require_in: + - service: dimension_service + +dimension_service: + service.running: + - name: dimension + - enable: True + - require: + - service: synapse_service + +dimension_restart: + module.wait: + - name: service.restart + - m_name: dimension + - require: + - service: synapse_service + - service: dimension_service diff --git a/salt/profile/matrix/files/config-dimension.yaml b/salt/profile/matrix/files/config-dimension.yaml new file mode 100644 index 0000000..456b389 --- /dev/null +++ b/salt/profile/matrix/files/config-dimension.yaml @@ -0,0 +1,102 @@ +# The web settings for the service (API and UI). +# It is best to have this run on localhost and use a reverse proxy to access Dimension. +web: + port: 8184 + address: '0.0.0.0' + +# Homeserver configuration +homeserver: + # The domain name of the homeserver. This is used in many places, such as with go-neb + # setups, to identify the homeserver. + name: "opensuse.org" + + # The URL that Dimension, go-neb, and other services provisioned by Dimension should + # use to access the homeserver with. + clientServerUrl: "https://matrix.opensuse.org" + + # The URL that Dimension should use when trying to communicate with federated APIs on + # the homeserver. If not supplied or left empty Dimension will try to resolve the address + # through the normal federation process. + #federationUrl: "https://t2bot.io:8448" + + # The URL that Dimension will redirect media requests to for downloading media such as + # stickers. If not supplied or left empty Dimension will use the clientServerUrl. + #mediaUrl: "https://t2bot.io" + + # The access token Dimension should use for miscellaneous access to the homeserver, and + # for tracking custom sticker pack updates. This should be a user configured on the homeserver + # and be dedicated to Dimension (create a user named "dimension" on your homeserver). For + # information on how to acquire an access token, visit https://t2bot.io/docs/access_tokens + accessToken: "something" + +# These users can modify the integrations this Dimension supports. +# To access the admin interface, open Dimension in Riot and click the settings icon. +admins: + - "@hellcp:opensuse.org" + +# IPs and CIDR ranges listed here will be blocked from being widgets. +# Note: Widgets may still be embedded with restricted content, although not through Dimension directly. +widgetBlacklist: + - 10.0.0.0/8 + - 172.16.0.0/12 + - 192.168.0.0/16 + - 127.0.0.0/8 + +database: + # Where the database for Dimension is + file: "dimension.db" + + # Where to store misc information for the utility bot account. + botData: "dimension.bot.json" + +# Display settings that apply to self-hosted go-neb instances +goneb: + # The avatars to set for each bot. Usually these don't need to be changed, however if your homeserver + # is not able to reach t2bot.io then you should specify your own here. To not use an avatar for a bot, + # make the bot's avatar an empty string. + avatars: + giphy: "mxc://t2bot.io/c5eaab3ef0133c1a61d3c849026deb27" + imgur: "mxc://t2bot.io/6749eaf2b302bb2188ae931b2eeb1513" + github: "mxc://t2bot.io/905b64b3cd8e2347f91a60c5eb0832e1" + wikipedia: "mxc://t2bot.io/7edfb54e9ad9e13fec0df22636feedf1" + travisci: "mxc://t2bot.io/7f4703126906fab8bb27df34a17707a8" + rss: "mxc://t2bot.io/aace4fcbd045f30afc1b4e5f0928f2f3" + google: "mxc://t2bot.io/636ad10742b66c4729bf89881a505142" + guggy: "mxc://t2bot.io/e7ef0ed0ba651aaf907655704f9a7526" + echo: "mxc://t2bot.io/3407ff2db96b4e954fcbf2c6c0415a13" + circleci: "mxc://t2bot.io/cf7d875845a82a6b21f5f66de78f6bee" + jira: "mxc://t2bot.io/f4a38ebcc4280ba5b950163ca3e7c329" + +# Settings for interacting with Telegram. Currently only applies for importing +# sticker packs from Telegram. +telegram: + # Talk to @BotFather on Telegram to get a token + botToken: "{{ pillar['profile']['matrix']['telegram']['bot_token'] }}" + +# Custom sticker pack options. +# Largely based on https://github.com/turt2live/matrix-sticker-manager +stickers: + # Whether or not to allow people to add custom sticker packs + enabled: true + + # The sticker manager bot to promote + stickerBot: "@stickers:t2bot.io" + + # The sticker manager URL to promote + managerUrl: "https://stickers.t2bot.io" + +# Settings for how Dimension is represented to the public +dimension: + # This is where Dimension is accessible from clients. Be sure to set this + # to your own Dimension instance. + publicUrl: "https://dimension.opensuse.org" + +# Settings for controlling how logging works +logging: + file: logs/dimension.log + console: true + consoleLevel: info + fileLevel: verbose + rotate: + size: 52428800 # bytes, default is 50mb + count: 5 diff --git a/salt/profile/matrix/files/dimension.service b/salt/profile/matrix/files/dimension.service new file mode 100644 index 0000000..22cae0d --- /dev/null +++ b/salt/profile/matrix/files/dimension.service @@ -0,0 +1,16 @@ +[Unit] +Description=Matrix Dimension + +[Service] +Type=simple +Restart=on-failure +RestartSec=3 + +User=synapse +Group=synapse +WorkingDirectory=/var/lib/matrix-synapse/dimension/ +Environment="NODE_VERSION=10 NODE_ENV=production" +ExecStart=/usr/bin/npm run start:app + +[Install] +WantedBy=multi-user.target diff --git a/salt/profile/matrix/init.sls b/salt/profile/matrix/init.sls index 5b22e8f..e0d13cf 100644 --- a/salt/profile/matrix/init.sls +++ b/salt/profile/matrix/init.sls @@ -1,5 +1,10 @@ {% set roles = salt['grains.get']('roles', []) %} +riot_dependencies: + pkg.installed: + - pkgs: + - riot-web + synapse_service: service.running: - name: synapse diff --git a/salt/profile/matrix/telegram.sls b/salt/profile/matrix/telegram.sls index 1a076a0..e1ebe79 100644 --- a/salt/profile/matrix/telegram.sls +++ b/salt/profile/matrix/telegram.sls @@ -4,6 +4,8 @@ appservice_pgks: pkg.installed: - pkgs: - python3-mautrix-telegram + # Required for webm for stickers + - ffmpeg /var/lib/matrix-synapse/telegram: file.directory: