From 136bfe1e0dc4507f7525382443deeb3b99e3205d Mon Sep 17 00:00:00 2001 From: Peter Ludikovsky Date: Thu, 26 Oct 2017 14:12:07 +0200 Subject: Initial commit --- .gitignore | 1 + 01-basis.yml | 15 ++ 02-variablen.yml | 19 ++ 03-module.yml | 25 +++ matrix/files/homeserver.yaml.j2 | 443 +++++++++++++++++++++++++++++++++++++++ matrix/files/nginx.j2 | 63 ++++++ matrix/files/report_stats.yaml | 1 + matrix/files/server_name.yaml.j2 | 1 + matrix/files/synapse.list | 2 + matrix/matrix.usrspace.at.key | 51 +++++ matrix/matrix.usrspace.at.pem | 33 +++ matrix/synapse01.yml | 63 ++++++ matrix/synapse02.yml | 100 +++++++++ 13 files changed, 817 insertions(+) create mode 100644 .gitignore create mode 100644 01-basis.yml create mode 100644 02-variablen.yml create mode 100644 03-module.yml create mode 100644 matrix/files/homeserver.yaml.j2 create mode 100644 matrix/files/nginx.j2 create mode 100644 matrix/files/report_stats.yaml create mode 100644 matrix/files/server_name.yaml.j2 create mode 100644 matrix/files/synapse.list create mode 100644 matrix/matrix.usrspace.at.key create mode 100644 matrix/matrix.usrspace.at.pem create mode 100644 matrix/synapse01.yml create mode 100644 matrix/synapse02.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8b42eb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.retry diff --git a/01-basis.yml b/01-basis.yml new file mode 100644 index 0000000..677a8e2 --- /dev/null +++ b/01-basis.yml @@ -0,0 +1,15 @@ +--- +# Auf welchen Hosts soll das Playbook laufen? (Name oder IP) +- hosts: localhost + # root werden? + become: yes + # Die Aufgaben + tasks: + - name: Admin-Extras installieren + shell: 'apt-get -y install htop tmux sudo vim-nox thefuck' + - name: Unnötiges löschen + shell: 'apt-get -y purge nano vim-tiny' + - name: SSH aktivieren + shell: 'update-rc.d ssh enable' + - name: SSH starten + shell: 'invoke-rc.d ssh start' diff --git a/02-variablen.yml b/02-variablen.yml new file mode 100644 index 0000000..3e79cea --- /dev/null +++ b/02-variablen.yml @@ -0,0 +1,19 @@ +--- +# Auf welchen Hosts soll das Playbook laufen? (Name oder IP) +- hosts: localhost + # root werden? + become: yes + # Variablen + vars: + packages_install: "htop tmux sudo vim-nox thefuck" + packages_remove: "nano vim-tiny" + # Die Aufgaben + tasks: + - name: Admin-Extras installieren + shell: "apt-get -y install {{ packages_install }}" + - name: Unnötiges löschen + shell: "apt-get -y purge {{ packages_remove }}" + - name: SSH aktivieren + shell: 'update-rc.d ssh enable' + - name: SSH starten + shell: 'invoke-rc.d ssh start' diff --git a/03-module.yml b/03-module.yml new file mode 100644 index 0000000..7f1166c --- /dev/null +++ b/03-module.yml @@ -0,0 +1,25 @@ +--- +# Auf welchen Hosts soll das Playbook laufen? (Name oder IP) +- hosts: localhost + # root werden? + become: yes + # Variablen + vars: + packages_install: [htop, tmux, sudo, vim-nox, thefuck] + packages_remove: [nano, vim-tiny] + # Die Aufgaben + tasks: + - name: Admin-Extras installieren + apt: + name: "{{ packages_install }}" + state: present + - name: Unnötiges löschen + apt: + name: "{{ packages_remove }}" + state: absent + purge: yes + - name: SSH aktivieren + service: + name: ssh + state: started + enabled: yes diff --git a/matrix/files/homeserver.yaml.j2 b/matrix/files/homeserver.yaml.j2 new file mode 100644 index 0000000..925029d --- /dev/null +++ b/matrix/files/homeserver.yaml.j2 @@ -0,0 +1,443 @@ +# vim:ft=yaml +# PEM encoded X509 certificate for TLS. +# You can replace the self-signed certificate that synapse +# autogenerates on launch with your own SSL certificate + key pair +# if you like. Any required intermediary certificates can be +# appended after the primary certificate in hierarchical order. +tls_certificate_path: "/etc/matrix-synapse/{{ federation_server }}.pem" + +# PEM encoded private key for TLS +tls_private_key_path: "/etc/matrix-synapse/{{ federation_server }}.key" + +# PEM dh parameters for ephemeral keys +#tls_dh_params_path: "/etc/matrix-synapse/dhparams_2048.pem" +tls_dh_params_path: "/etc/matrix-synapse/dhparams_4096.pem" + +# Don't bind to the https port +no_tls: False + + +## Server ## + +# When running as a daemon, the file to store the pid in +pid_file: "/var/run/matrix-synapse.pid" + +# Whether to serve a web client from the HTTP/HTTPS root resource. +web_client: False + +# The public-facing base URL for the client API (not including _matrix/...) +# public_baseurl: https://example.com:8448/ + +# Set the soft limit on the number of file descriptors synapse can use +# Zero is used to indicate synapse should set the soft limit to the +# hard limit. +soft_file_limit: 0 + +# The GC threshold parameters to pass to `gc.set_threshold`, if defined +# gc_thresholds: [700, 10, 10] + +# A list of other Home Servers to fetch the public room directory from +# and include in the public room directory of this home server +# This is a temporary stopgap solution to populate new server with a +# list of rooms until there exists a good solution of a decentralized +# room directory. +# secondary_directory_servers: +# - matrix.org +# - vector.im + +# List of ports that Synapse should listen on, their purpose and their +# configuration. +listeners: + # Main HTTPS listener + # For when matrix traffic is sent directly to synapse. + - + # The port to listen for HTTPS requests on. + port: 8448 + + # Local interface to listen on. + # The empty string will cause synapse to listen on all interfaces. + bind_address: '' + + # This is a 'http' listener, allows us to specify 'resources'. + type: http + + tls: true + + # Use the X-Forwarded-For (XFF) header as the client IP and not the + # actual client IP. + x_forwarded: false + + # List of HTTP resources to serve on this listener. + resources: + - + # List of resources to host on this listener. + names: + - client # The client-server APIs, both v1 and v2 + - webclient # The bundled webclient. + + # Should synapse compress HTTP responses to clients that support it? + # This should be disabled if running synapse behind a load balancer + # that can do automatic compression. + compress: true + + - names: [federation] # Federation APIs + compress: false + + # Unsecure HTTP listener, + # For when matrix traffic passes through loadbalancer that unwraps TLS. + - port: 8008 + tls: false + bind_address: '::1' + type: http + + x_forwarded: false + + resources: + - names: [client, webclient] + compress: true + - names: [federation] + compress: false + + # Turn on the twisted ssh manhole service on localhost on the given + # port. + # - port: 9000 + # bind_address: 127.0.0.1 + # type: manhole + + +# Database configuration +database: + # The database engine name + #name: "sqlite3" + name: psycopg2 + # Arguments to pass to the engine + args: + # Path to the database + #database: "/var/lib/matrix-synapse/homeserver.db" + user: "{{ dbuser }}" + password: "{{ dbpass }}" + database: "{{ database }}" + host: "localhost" + cp_min: 5 + cp_max: 10 + + +# Number of events to cache in memory. +event_cache_size: "10K" + + +# A yaml python logging config file +log_config: "/etc/matrix-synapse/log.yaml" + +# Stop twisted from discarding the stack traces of exceptions in +# deferreds by waiting a reactor tick before running a deferred's +# callbacks. +# full_twisted_stacktraces: true + + +## Ratelimiting ## + +# Number of messages a client can send per second +rc_messages_per_second: 0.2 + +# Number of message a client can send before being throttled +rc_message_burst_count: 10.0 + +# The federation window size in milliseconds +federation_rc_window_size: 1000 + +# The number of federation requests from a single server in a window +# before the server will delay processing the request. +federation_rc_sleep_limit: 10 + +# The duration in milliseconds to delay processing events from +# remote servers by if they go over the sleep limit. +federation_rc_sleep_delay: 500 + +# The maximum number of concurrent federation requests allowed +# from a single server +federation_rc_reject_limit: 50 + +# The number of federation requests to concurrently process from a +# single server +federation_rc_concurrent: 3 + + + +# Directory where uploaded images and attachments are stored. +media_store_path: "/var/lib/matrix-synapse/media" + +# The largest allowed upload size in bytes +max_upload_size: "10M" + +# Maximum number of pixels that will be thumbnailed +max_image_pixels: "32M" + +# Whether to generate new thumbnails on the fly to precisely match +# the resolution requested by the client. If true then whenever +# a new resolution is requested by the client the server will +# generate a new thumbnail. If false the server will pick a thumbnail +# from a precalculated list. +dynamic_thumbnails: false + +# List of thumbnail to precalculate when an image is uploaded. +thumbnail_sizes: +- width: 32 + height: 32 + method: crop +- width: 96 + height: 96 + method: crop +- width: 320 + height: 240 + method: scale +- width: 640 + height: 480 + method: scale +- width: 800 + height: 600 + method: scale + +# Is the preview URL API enabled? If enabled, you *must* specify +# an explicit url_preview_ip_range_blacklist of IPs that the spider is +# denied from accessing. +url_preview_enabled: False + +# List of IP address CIDR ranges that the URL preview spider is denied +# from accessing. There are no defaults: you must explicitly +# specify a list for URL previewing to work. You should specify any +# internal services in your network that you do not want synapse to try +# to connect to, otherwise anyone in any Matrix room could cause your +# synapse to issue arbitrary GET requests to your internal services, +# causing serious security issues. +# +# url_preview_ip_range_blacklist: +# - '127.0.0.0/8' +# - '10.0.0.0/8' +# - '172.16.0.0/12' +# - '192.168.0.0/16' +# +# List of IP address CIDR ranges that the URL preview spider is allowed +# to access even if they are specified in url_preview_ip_range_blacklist. +# This is useful for specifying exceptions to wide-ranging blacklisted +# target IP ranges - e.g. for enabling URL previews for a specific private +# website only visible in your network. +# +# url_preview_ip_range_whitelist: +# - '192.168.1.1' + +# Optional list of URL matches that the URL preview spider is +# denied from accessing. You should use url_preview_ip_range_blacklist +# in preference to this, otherwise someone could define a public DNS +# entry that points to a private IP address and circumvent the blacklist. +# This is more useful if you know there is an entire shape of URL that +# you know that will never want synapse to try to spider. +# +# Each list entry is a dictionary of url component attributes as returned +# by urlparse.urlsplit as applied to the absolute form of the URL. See +# https://docs.python.org/2/library/urlparse.html#urlparse.urlsplit +# The values of the dictionary are treated as an filename match pattern +# applied to that component of URLs, unless they start with a ^ in which +# case they are treated as a regular expression match. If all the +# specified component matches for a given list item succeed, the URL is +# blacklisted. +# +# url_preview_url_blacklist: +# # blacklist any URL with a username in its URI +# - username: '*' +# +# # blacklist all *.google.com URLs +# - netloc: 'google.com' +# - netloc: '*.google.com' +# +# # blacklist all plain HTTP URLs +# - scheme: 'http' +# +# # blacklist http(s)://www.acme.com/foo +# - netloc: 'www.acme.com' +# path: '/foo' +# +# # blacklist any URL with a literal IPv4 address +# - netloc: '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' + +# The largest allowed URL preview spidering size in bytes +max_spider_size: "10M" + + + + +## Captcha ## + +# This Home Server's ReCAPTCHA public key. +recaptcha_public_key: "YOUR_PUBLIC_KEY" + +# This Home Server's ReCAPTCHA private key. +recaptcha_private_key: "YOUR_PRIVATE_KEY" + +# Enables ReCaptcha checks when registering, preventing signup +# unless a captcha is answered. Requires a valid ReCaptcha +# public/private key. +enable_registration_captcha: False + +# A secret key used to bypass the captcha test entirely. +#captcha_bypass_secret: "YOUR_SECRET_HERE" + +# The API endpoint to use for verifying m.login.recaptcha responses. +recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify" + + +## Turn ## + +# The public URIs of the TURN server to give to clients +turn_uris: [] + +# The shared secret used to compute passwords for the TURN server +turn_shared_secret: "YOUR_SHARED_SECRET" + +# How long generated TURN credentials last +turn_user_lifetime: "1h" + + +## Registration ## + +# Enable registration for new users. +enable_registration: False + +# If set, allows registration by anyone who also has the shared +# secret, even if registration is otherwise disabled. +registration_shared_secret: PetersMatrixServer + +# Sets the expiry for the short term user creation in +# milliseconds. For instance the bellow duration is two weeks +# in milliseconds. +user_creation_max_duration: 1209600000 + +# Set the number of bcrypt rounds used to generate password hash. +# Larger numbers increase the work factor needed to generate the hash. +# The default number of rounds is 12. +bcrypt_rounds: 12 + +# Allows users to register as guests without a password/email/etc, and +# participate in rooms hosted on this server which have been made +# accessible to anonymous users. +allow_guest_access: False + +# The list of identity servers trusted to verify third party +# identifiers by this server. +trusted_third_party_id_servers: + - matrix.org + - vector.im + + +## Metrics ### + +# Enable collection and rendering of performance metrics +enable_metrics: False + +## API Configuration ## + +# A list of event types that will be included in the room_invite_state +room_invite_state_types: + - "m.room.join_rules" + - "m.room.canonical_alias" + - "m.room.avatar" + - "m.room.name" + + +# A list of application service config file to use +app_service_config_files: [] + + +# macaroon_secret_key: + +# Used to enable access token expiration. +expire_access_token: False + +## Signing Keys ## + +# Path to the signing key to sign messages with +signing_key_path: "/etc/matrix-synapse/homeserver.signing.key" + +# The keys that the server used to sign messages with but won't use +# to sign new messages. E.g. it has lost its private key +old_signing_keys: {} +# "ed25519:auto": +# # Base64 encoded public key +# key: "The public part of your old signing key." +# # Millisecond POSIX timestamp when the key expired. +# expired_ts: 123456789123 + +# How long key response published by this server is valid for. +# Used to set the valid_until_ts in /key/v2 APIs. +# Determines how quickly servers will query to check which keys +# are still valid. +key_refresh_interval: "1d" # 1 Day. + +# The trusted servers to download signing keys from. +perspectives: + servers: + "matrix.org": + verify_keys: + "ed25519:auto": + key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw" + + + +# Enable SAML2 for registration and login. Uses pysaml2 +# config_path: Path to the sp_conf.py configuration file +# idp_redirect_url: Identity provider URL which will redirect +# the user back to /login/saml2 with proper info. +# See pysaml2 docs for format of config. +#saml2_config: +# enabled: true +# config_path: "/home/erikj/git/synapse/sp_conf.py" +# idp_redirect_url: "http://test/idp" + + + +# Enable CAS for registration and login. +#cas_config: +# enabled: true +# server_url: "https://cas-server.com" +# service_url: "https://homesever.domain.com:8448" +# #required_attributes: +# # name: value + + +# The JWT needs to contain a globally unique "sub" (subject) claim. +# +# jwt_config: +# enabled: true +# secret: "a secret" +# algorithm: "HS256" + + +# ldap_config: +# enabled: true +# server: "ldap://localhost" +# port: 389 +# tls: false +# search_base: "ou=Users,dc=example,dc=com" +# search_property: "cn" +# email_property: "email" +# full_name_property: "givenName" + + + +# Enable password for login. +password_config: + enabled: true + + + +# Enable sending emails for notification events +#email: +# enable_notifs: false +# smtp_host: "localhost" +# smtp_port: 25 +# notif_from: "Your Friendly %(app)s Home Server " +# app_name: Matrix +# template_dir: res/templates +# notif_template_html: notif_mail.html +# notif_template_text: notif_mail.txt +# notif_for_new_users: True diff --git a/matrix/files/nginx.j2 b/matrix/files/nginx.j2 new file mode 100644 index 0000000..bce4643 --- /dev/null +++ b/matrix/files/nginx.j2 @@ -0,0 +1,63 @@ +server { + listen 80; + server_name {{ federation_server }}; + access_log /var/log/nginx/{{ federation_server }}/access.log combined; + error_log /var/log/nginx/{{ federation_server }}/error.log; + root /var/www/{{ federation_server }}; + +{% if ssl_available %} + location / { + return 301 https://{{ federation_server }}$request_uri; + rewrite ^ https://{{ federation_server }}$request_uri permanent; + } +{% endif %} + if ($request_uri ~ " ") { + return 444; + } + if ( $request_uri ~ ^/smoke/(.*)$ ) { + return 444; + } +} +{% if ssl_available %} +server { + listen 443; + server_name {{ federation_server }}; + access_log /var/log/nginx/{{ federation_server }}/access.ssl.log combined; + error_log /var/log/nginx/{{ federation_server }}/error.ssl.log; + root /var/www/{{ federation_server }}; + + if ($request_uri ~ " ") { + return 444; + } + if ( $request_uri ~ ^/smoke/(.*)$ ) { + return 444; + } + + location / { + proxy_pass http://[::1]:8008/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + gzip_static on; + etag on; + + ssl on; + ssl_certificate /etc/ssl/certs/{{ federation_server }}.pem; + ssl_certificate_key /etc/ssl/private/{{ federation_server }}.key; + ssl_session_timeout 5m; + ssl_protocols TLSv1.2; + ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA"; + ssl_prefer_server_ciphers on; + ssl_stapling on; + ssl_stapling_verify on; + ssl_dhparam /etc/ssl/private/dhparams_4096.pem; + ssl_ecdh_curve secp384r1; + ssl_session_tickets off; + ssl_session_cache shared:matrix:2M; + add_header X-Frame-Options DENY; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; + resolver 8.8.8.8 8.8.4.4 valid=300s; + resolver_timeout 5s; +} +{% endif %} diff --git a/matrix/files/report_stats.yaml b/matrix/files/report_stats.yaml new file mode 100644 index 0000000..d84890a --- /dev/null +++ b/matrix/files/report_stats.yaml @@ -0,0 +1 @@ +report_stats: false diff --git a/matrix/files/server_name.yaml.j2 b/matrix/files/server_name.yaml.j2 new file mode 100644 index 0000000..bbf8dcd --- /dev/null +++ b/matrix/files/server_name.yaml.j2 @@ -0,0 +1 @@ +server_name: {{ federation_server }} diff --git a/matrix/files/synapse.list b/matrix/files/synapse.list new file mode 100644 index 0000000..1fdd06e --- /dev/null +++ b/matrix/files/synapse.list @@ -0,0 +1,2 @@ +deb http://matrix.org/packages/debian/ stretch main +deb-src http://matrix.org/packages/debian/ stretch main diff --git a/matrix/matrix.usrspace.at.key b/matrix/matrix.usrspace.at.key new file mode 100644 index 0000000..83a912d --- /dev/null +++ b/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RtFHODXZoymtPv8YrkFfll296yQAoTtARVN8= +-----END RSA PRIVATE KEY----- diff --git a/matrix/matrix.usrspace.at.pem b/matrix/matrix.usrspace.at.pem new file mode 100644 index 0000000..4c330cd --- /dev/null +++ b/matrix/matrix.usrspace.at.pem @@ -0,0 +1,33 @@ +-----BEGIN CERTIFICATE----- +MIIFsDCCA5igAwIBAgIJALPXc8UrkLdMMA0GCSqGSIb3DQEBCwUAMG0xCzAJBgNV +BAYTAkFUMRYwFAYDVQQIDA1Mb3dlciBBdXN0cmlhMRQwEgYDVQQHDAtMZW9iZXJz +ZG9yZjETMBEGA1UECgwKL3Vzci9zcGFjZTEbMBkGA1UEAwwSbWF0cml4LnVzcnNw +YWNlLmF0MB4XDTE3MTAyNDE5MzIxNFoXDTE4MTAyNDE5MzIxNFowbTELMAkGA1UE +BhMCQVQxFjAUBgNVBAgMDUxvd2VyIEF1c3RyaWExFDASBgNVBAcMC0xlb2JlcnNk +b3JmMRMwEQYDVQQKDAovdXNyL3NwYWNlMRswGQYDVQQDDBJtYXRyaXgudXNyc3Bh +Y2UuYXQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCxzvg0L+GAlYUT +KNEpib5plJ2VY+f+Ud/COW91M3eNWrPvvAr2EhNNqnorT/SEiEuRgxC9FammYc0a +vjdJx/SbG98xBms7c0NSrcPzCCTA5350+pqk1gNtidS12MSUUB481s+7dYQoZD88 +jk/YdNgWGwNRw9dljgObfFpdJqiYGqtIWN7JKCUsh1CMPGUMOtXOvVg5ASLvU861 +VnZw+O+rEXwXDs6N0igexMgb58fnRflKTgdEJxsQvN3IyzOnDJlOKwP3QZ+X5PB1 +D5vwAByVlT0vftbQW/eaoDSwAlQTfrQq+fa1cxmTWm50NrAMgU7a4FiqUf/iuHCp +dD1fuQaQObvuYs1bloo8RLOlr2QLNDgGgnkryXXUe5GkTIetVgT4oH/O/xgWM0fB +5Cd/dkFqYiXC43z3KOgh/z9Izd6UGKc3IdU0mh4BGT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vgp2fyu/Cwb6U= +-----END CERTIFICATE----- diff --git a/matrix/synapse01.yml b/matrix/synapse01.yml new file mode 100644 index 0000000..d7f38ab --- /dev/null +++ b/matrix/synapse01.yml @@ -0,0 +1,63 @@ +--- +- hosts: localhost + remote_user: peter + become: yes + vars: + federation_server: "matrix.example.com" + client_server: "example.com" + dbuser: "synapse" + dbpass: "" + database: "synapse" + packages: [matrix-synapse, postgresql, nginx, python-psycopg2] + synapse_repo: "files/synapse.list" + synapse_config: "files/homeserver.yaml.j2" + nginx_config: "files/nginx.j2" + ssl_available: false + tasks: + - name: Get hostname + shell: hostname + register: hostname + become: no + - name: Install Synapse repo + copy: + src: "{{ synapse_repo }}" + dest: /etc/apt/sources.list.d/synapse.list + - name: Install Synapse repo key + apt_key: + url: https://matrix.org/packages/debian/repo-key.asc + state: present + - name: Install Packages + apt: + name: "{{ packages }}" + update_cache: yes + state: installed + install_recommends: no + - name: Create ACME dir + file: + path: "/var/www/{{ federation_server }}" + state: directory + owner: www-data + group: www-data + - name: Create nginx log dir + file: + path: "/var/log/nginx/{{ federation_server }}" + state: directory + owner: www-data + group: www-data + - name: Setup nginx w/o HTTPS + template: + src: "{{ nginx_config }}" + dest: "/etc/nginx/sites-available/{{ federation_server }}.conf" + - name: Link nginx config + file: + path: "/etc/nginx/sites-enabled/{{ federation_server }}.conf" + src: "/etc/nginx/sites-available/{{ federation_server }}.conf" + state: link + - name: Start nginx + service: + name: nginx + state: started + enabled: yes + - name: Done part 1 + debug: + msg: "Pre-Setup done, create a Key and Certificate and move them to /etc/ssl/certs/{{ federation_server }}.pem and /etc/ssl/certs/{{ federation_server }}.pem" diff --git a/matrix/synapse02.yml b/matrix/synapse02.yml new file mode 100644 index 0000000..04becc8 --- /dev/null +++ b/matrix/synapse02.yml @@ -0,0 +1,100 @@ +# vim: ts=2 shiftwidth=2 +--- +- hosts: localhost + remote_user: peter + become: yes + vars: + federation_server: "matrix.example.com" + client_server: "example.com" + dbuser: "synapse" + dbpass: "" + database: "synapse" + packages: [matrix-synapse, postgresql, nginx, python-psycopg2] + synapse_repo: "files/synapse.list" + synapse_config: "files/homeserver.yaml.j2" + synapse_config_server: "files/server_name.yaml.j2" + synapse_config_report: "files/report_stats.yaml" + nginx_config: "files/nginx.j2" + ssl_available: true + tasks: + - name: Get hostname + shell: hostname + register: hostname + become: no + - name: Setup nginx w/ HTTPS + template: + src: "{{ nginx_config }}" + dest: "/etc/nginx/sites-available/{{ federation_server }}.conf" + - name: Reload nginx + service: + name: nginx + state: reloaded + - name: Activate PostgreSQL + service: + name: postgresql + state: started + enabled: yes + - name: Create DB user + become_user: postgres + postgresql_user: + name: "{{ dbuser }}" + state: present + role_attr_flags: NOSUPERUSER,NOCREATEROLE,NOCREATEDB + password: "{{ dbpass }}" + encrypted: no + - name: Create DB + become_user: postgres + postgresql_db: + name: "{{ database }}" + state: present + owner: "{{ dbuser }}" + encoding: UTF8 + lc_collate: C + lc_ctype: C + template: template0 + - name: Configure Synapse (main) + template: + src: "{{ synapse_config }}" + dest: /etc/matrix-synapse/homeserver.yaml + force: yes + owner: matrix-synapse + group: nogroup + - name: Configure Synapse (server name) + template: + src: "{{ synapse_config_server }}" + dest: /etc/matrix-synapse/conf.d/server_name.yaml + force: yes + owner: matrix-synapse + group: nogroup + - name: Configure Synapse (stats) + template: + src: "{{ synapse_config_report }}" + dest: /etc/matrix-synapse/conf.d/report_stats.yaml + force: yes + owner: matrix-synapse + group: nogroup + - name: Copy Cert for Synapse + copy: + remote_src: yes + src: "/etc/ssl/certs/{{ federation_server }}.pem" + dest: "/etc/matrix-synapse/{{ federation_server }}.pem" + owner: matrix-synapse + group: nogroup + - name: Copy Key for Synapse + copy: + remote_src: yes + src: "/etc/ssl/private/{{ federation_server }}.key" + dest: "/etc/matrix-synapse/{{ federation_server }}.key" + owner: matrix-synapse + group: nogroup + - name: Start Synapse + service: + name: matrix-synapse + state: started + enabled: yes + - name: Done + debug: + msg: |- + What to do: + * Create a user via register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml https://localhost:8448 + * Create the required DNS entries for federation -- cgit v1.2.3