diff --git a/.gitignore b/.gitignore index 8000dd9..f7d38e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .vagrant +hosts.ini +ubuntu-bionic-18.04-cloudimg-console.log \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 3b30d30..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,65 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "ubuntu/bionic64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - config.vm.network "forwarded_port", guest: 8008, host: 8008 - config.vm.network "forwarded_port", guest: 8448, host: 8448 - config.vm.network "forwarded_port", guest: 443, host: 443 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # Display the VirtualBox GUI when booting the machine - # vb.gui = true - - # Customize the amount of memory on the VM: - vb.memory = "4096" - end - - config.vm.provision "ansible" do |ansible| - ansible.playbook = "setup.yml" - end -end diff --git a/certbot.yml b/certbot.yml deleted file mode 100644 index 433ce00..0000000 --- a/certbot.yml +++ /dev/null @@ -1,9 +0,0 @@ -- hosts: synapse - vars: - - certbot_certs: - - email: core@fuz.re - domains: - - "{{ ansible_host }}" - # - riot.fuz.re - roles: - - ansible-role-certbot diff --git a/group_vars/all/vars.yml b/group_vars/all/vars.yml deleted file mode 100644 index fcb985e..0000000 --- a/group_vars/all/vars.yml +++ /dev/null @@ -1,3 +0,0 @@ - synapse_dbname: synapse - synapse_dbuser: synapse_db - synapse_dbpw: synapse_db \ No newline at end of file diff --git a/main.yml b/main.yml index fa997bf..7ada3ff 100644 --- a/main.yml +++ b/main.yml @@ -1,42 +1,17 @@ --- - - hosts: - - synapse - # vars: - # - + - sonic-preprod handlers: - name: reboot reboot: pre_tasks: - - apt: update_cache: yes + # - apt: + # name: python-pip + # roles: + # - geerlingguy.pip - - name: Disable IPv6 - blockinfile: - path: /etc/sysctl.conf - block: | - net.ipv6.conf.all.disable_ipv6 = 1 - net.ipv6.conf.default.disable_ipv6 = 1 - net.ipv6.conf.lo.disable_ipv6 = 1 - notify: reboot - - - name: apply ipv6 disable - command: sysctl -p - become: yes - - - name: check ipv6 state - shell: cat /proc/sys/net/ipv6/conf/all/disable_ipv6 - register: command_result - failed_when: "'1' not in command_result.stdout" - - - apt: - name: python-pip - roles: - - geerlingguy.pip - -- import_playbook: postgres.yml -- import_playbook: certbot.yml -# todo: create synapse user -- import_playbook: synapse.yml \ No newline at end of file +# - import_playbook: nginx-certbot.yml +- import_playbook: matrix.yml \ No newline at end of file diff --git a/matrix-telegram-bridge.yml b/matrix-telegram-bridge.yml new file mode 100644 index 0000000..5f1800e --- /dev/null +++ b/matrix-telegram-bridge.yml @@ -0,0 +1,11 @@ +# https://github.com/tulir/mautrix-telegram/wiki/Bridge-setup-with-Docker + +# version: "3.7" + +# services: +# mautrix-telegram: +# container_name: mautrix-telegram +# image: dock.mau.dev/tulir/mautrix-telegram: +# restart: unless-stopped +# volumes: +# - .:/data \ No newline at end of file diff --git a/matrix.yml b/matrix.yml new file mode 100644 index 0000000..55206b7 --- /dev/null +++ b/matrix.yml @@ -0,0 +1,55 @@ +--- +- hosts: synapse +# todo: create user for synapse + vars: + matrix_synapse_version: "v1.5.1-py3" + # matrix_synapse_version: "v1.5.1" + matrix_server_name: matrix-sonic-beta.local + + + matrix_synapse_pg_host: synapse-postgres + # matrix_synapse_pg_user: "" + # matrix_synapse_pg_pass: "" + # matrix_synapse_pg_db: "" + + matrix_synapse_report_stats: false + + # matrix_synapse_extra_config: + # no_tls: true + + tasks: + # - docker_volume: + # name: synapse-data + + - template: + src: templates/synapse_homeserver.yaml.j2 + dest: /synapse-data/homeserver.yaml + +# - docker_container: +# name: synapse-fuz-beta # required. Assign a name to a new container or match an existing container.,When identifying an existing container name may be a name or a long or short container ID. +# image: "matrixdotorg/synapse:{{ matrix_synapse_version }}" +# published_ports: 8008:8008 +# domainname: undefined # not required. Container domainname. +# # env_file: undefined # not required. Path to a file, present on the target, containing environment variables I(FOO=BAR).,If variable also present in C(env), then C(env) value will override. +# hostname: undefined # not required. Container hostname. +# state: started + + + +# env: +# SYNAPSE_SERVER_NAME: "{{ matrix_server_name }}" +# SYNAPSE_REPORT_STATS: {{ matrix_synapse_report_stats }} +# # SYNAPSE_CONFIG_DIR: where additional config files (such as the log config and event signing key) will be stored. Defaults to /data. +# # SYNAPSE_CONFIG_PATH: path to the file to be generated. Defaults to /homeserver.yaml. +# # SYNAPSE_DATA_DIR: where the generated config will put persistent data such as the datatase and media store. Defaults to /data. +# keep_volumes: yes # not required. Retain volumes associated with a removed container. +# volumes: /synapse-data:/data # not required. List of volumes to mount within the container.,Use docker CLI-style syntax: C(/host:/container[:mode]),You can specify a read mode for the mount with either C(ro) or C(rw).,SELinux hosts can additionally use C(z) or C(Z) to use a shared or private label for the volume. +# detach: true + - template: + src: templates/docker-compose-matrix.yml.j2 + dest: /synapse-data/homeserver.yaml + + - name: Create and start matrix services + docker_compose: + project_src: matrix + register: output \ No newline at end of file diff --git a/nextcloud.yml b/nextcloud.yml deleted file mode 100644 index 5017995..0000000 --- a/nextcloud.yml +++ /dev/null @@ -1 +0,0 @@ -# Nextcloud with Calendar, Notes and Kanban enabled. \ No newline at end of file diff --git a/postgres.yml b/postgres.yml deleted file mode 100644 index d91c93b..0000000 --- a/postgres.yml +++ /dev/null @@ -1,28 +0,0 @@ -- hosts: synapse - # become: yes - pre_tasks: - - apt: - name: sudo - - lineinfile: - path: /etc/sudoers - line: 'root ALL = (ALL) ALL' - tasks: - - pip: - name: psycopg2 - state: present - roles: - - role: geerlingguy.postgresql - postgresql_databases: - - name: "{{ synapse_dbname }}" - postgresql_users: - - name: "{{ synapse_dbuser }}" - password: "{{ synapse_dbpw }}" - postgresql_global_config_options: - - option: listen_addresses - value: "*" - - - # username: "postgres", - # password: "postgres", - # database: "imago_dev", - # hostname: "localhost", \ No newline at end of file diff --git a/requirements.yml b/requirements.yml index d2499fb..ca35352 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,8 +1,8 @@ # from galaxy -- src: geerlingguy.pip -- src: geerlingguy.postgresql -- src: https://github.com/geerlingguy/ansible-role-certbot - scm: git +# - src: geerlingguy.pip +# - src: geerlingguy.postgresql +# - src: https://github.com/geerlingguy/ansible-role-certbot +# scm: git # from GitHub, overriding the name and specifying a specific tag # - src: https://github.com/bennojoy/nginx @@ -15,6 +15,6 @@ # from GitLab or other git-based scm, using git+ssh -- src: https://gitlab.com/famedly/ansible/synapse - scm: git +# - src: https://gitlab.com/famedly/ansible/synapse +# scm: git # version: "0.1" # quoted, so YAML doesn't parse this as a floating-point value diff --git a/roles/ansible-role-certbot/.gitignore b/roles/ansible-role-certbot/.gitignore deleted file mode 100644 index f56f5b5..0000000 --- a/roles/ansible-role-certbot/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.retry -*/__pycache__ -*.pyc diff --git a/roles/ansible-role-certbot/.travis.yml b/roles/ansible-role-certbot/.travis.yml deleted file mode 100644 index 6e475ce..0000000 --- a/roles/ansible-role-certbot/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -language: python -services: docker - -env: - global: - - ROLE_NAME: certbot - matrix: - - MOLECULE_DISTRO: centos7 - - MOLECULE_DISTRO: centos6 - MOLECULE_PLAYBOOK: playbook-source-install.yml - - MOLECULE_DISTRO: ubuntu1804 - - MOLECULE_DISTRO: ubuntu1604 - - MOLECULE_DISTRO: ubuntu1404 - MOLECULE_PLAYBOOK: playbook-source-install.yml - - MOLECULE_DISTRO: debian9 - -install: - # Install test dependencies. - - pip install molecule docker - -before_script: - # Use actual Ansible Galaxy role name for the project directory. - - cd ../ - - mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME - - cd geerlingguy.$ROLE_NAME - -script: - # Run tests. - - molecule test - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ansible-role-certbot/LICENSE b/roles/ansible-role-certbot/LICENSE deleted file mode 100644 index 4275cf3..0000000 --- a/roles/ansible-role-certbot/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Jeff Geerling - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/roles/ansible-role-certbot/README.md b/roles/ansible-role-certbot/README.md deleted file mode 100644 index a720e0d..0000000 --- a/roles/ansible-role-certbot/README.md +++ /dev/null @@ -1,140 +0,0 @@ -# Ansible Role: Certbot (for Let's Encrypt) - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-certbot.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-certbot) - -Installs and configures Certbot (for Let's Encrypt). - -## Requirements - -If installing from source, Git is required. You can install Git using the `geerlingguy.git` role. - -Generally, installing from source (see section `Source Installation from Git`) leads to a better experience using Certbot and Let's Encrypt, especially if you're using an older OS release. - -## Role Variables - -The variable `certbot_install_from_source` controls whether to install Certbot from Git or package management. The latter is the default, so the variable defaults to `no`. - - certbot_auto_renew: true - certbot_auto_renew_user: "{{ ansible_user | default(lookup('env', 'USER')) }}" - certbot_auto_renew_hour: "3" - certbot_auto_renew_minute: "30" - certbot_auto_renew_options: "--quiet --no-self-upgrade" - -By default, this role configures a cron job to run under the provided user account at the given hour and minute, every day. The defaults run `certbot renew` (or `certbot-auto renew`) via cron every day at 03:30:00 by the user you use in your Ansible playbook. It's preferred that you set a custom user/hour/minute so the renewal is during a low-traffic period and done by a non-root user account. - -### Automatic Certificate Generation - -Currently there is one built-in method for generating new certificates using this role: `standalone`. Other methods (e.g. using nginx or apache and a webroot) may be added in the future. - -**For a complete example**: see the fully functional test playbook in [molecule/default/playbook-standalone-nginx-aws.yml](molecule/default/playbook-standalone-nginx-aws.yml). - - certbot_create_if_missing: false - certbot_create_method: standalone - -Set `certbot_create_if_missing` to `yes` or `True` to let this role generate certs. Set the method used for generating certs with the `certbot_create_method` variable—current allowed values include: `standalone`. - - certbot_admin_email: email@example.com - -The email address used to agree to Let's Encrypt's TOS and subscribe to cert-related notifications. This should be customized and set to an email address that you or your organization regularly monitors. - - certbot_certs: [] - # - email: janedoe@example.com - # domains: - # - example1.com - # - example2.com - # - domains: - # - example3.com - -A list of domains (and other data) for which certs should be generated. You can add an `email` key to any list item to override the `certbot_admin_email`. - - certbot_create_command: "{{ certbot_script }} certonly --standalone --noninteractive --agree-tos --email {{ cert_item.email | default(certbot_admin_email) }} -d {{ cert_item.domains | join(',') }}" - -The `certbot_create_command` defines the command used to generate the cert. - -#### Standalone Certificate Generation - - certbot_create_standalone_stop_services: - - nginx - -Services that should be stopped while `certbot` runs it's own standalone server on ports 80 and 443. If you're running Apache, set this to `apache2` (Ubuntu), or `httpd` (RHEL), or if you have Nginx on port 443 and something else on port 80 (e.g. Varnish, a Java app, or something else), add it to the list so it is stopped when the certificate is generated. - -These services will only be stopped the first time a new cert is generated. - -### Source Installation from Git - -You can install Certbot from it's Git source repository if desired. This might be useful in several cases, but especially when older distributions don't have Certbot packages available (e.g. CentOS < 7, Ubuntu < 16.10 and Debian < 8). - - certbot_install_from_source: false - certbot_repo: https://github.com/certbot/certbot.git - certbot_version: master - certbot_keep_updated: true - -Certbot Git repository options. To install from source, set `certbot_install_from_source` to `yes`. This clones the configured `certbot_repo`, respecting the `certbot_version` setting. If `certbot_keep_updated` is set to `yes`, the repository is updated every time this role runs. - - certbot_dir: /opt/certbot - -The directory inside which Certbot will be cloned. - -### Wildcard Certificates - -Let's Encrypt supports [generating wildcard certificates](https://community.letsencrypt.org/t/acme-v2-and-wildcard-certificate-support-is-live/55579), but the process for generating and using them is slightly more involved. See comments in [this pull request](https://github.com/geerlingguy/ansible-role-certbot/pull/60#issuecomment-423919284) for an example of how to use this role to maintain wildcard certs. - -Michael Porter also has a walkthrough of [Creating A Let’s Encrypt Wildcard Cert With Ansible](https://www.michaelpporter.com/2018/09/creating-a-wildcard-cert-with-ansible/), specifically with Cloudflare. - -## Dependencies - -None. - -## Example Playbook - - - hosts: servers - - vars: - certbot_auto_renew_user: your_username_here - certbot_auto_renew_minute: "20" - certbot_auto_renew_hour: "5" - - roles: - - geerlingguy.certbot - -See other examples in the `tests/` directory. - -### Manually creating certificates with certbot - -_Note: You can have this role automatically generate certificates; see the "Automatic Certificate Generation" documentation above._ - -You can manually create certificates using the `certbot` (or `certbot-auto`) script (use `letsencrypt` on Ubuntu 16.04, or use `/opt/certbot/certbot-auto` if installing from source/Git. Here are some example commands to configure certificates with Certbot: - - # Automatically add certs for all Apache virtualhosts (use with caution!). - certbot --apache - - # Generate certs, but don't modify Apache configuration (safer). - certbot --apache certonly - -If you want to fully automate the process of adding a new certificate, but don't want to use this role's built in functionality, you can do so using the command line options to register, accept the terms of service, and then generate a cert using the standalone server: - - 1. Make sure any services listening on ports 80 and 443 (Apache, Nginx, Varnish, etc.) are stopped. - 2. Register with something like `certbot register --agree-tos --email [your-email@example.com]` - - Note: You won't need to do this step in the future, when generating additional certs on the same server. - 3. Generate a cert for a domain whose DNS points to this server: `certbot certonly --noninteractive --standalone -d example.com -d www.example.com` - 4. Re-start whatever was listening on ports 80 and 443 before. - 5. Update your webserver's virtualhost TLS configuration to point at the new certificate (`fullchain.pem`) and private key (`privkey.pem`) Certbot just generated for the domain you passed in the `certbot` command. - 6. Reload or restart your webserver so it uses the new HTTPS virtualhost configuration. - -### Certbot certificate auto-renewal - -By default, this role adds a cron job that will renew all installed certificates once per day at the hour and minute of your choosing. - -You can test the auto-renewal (without actually renewing the cert) with the command: - - /opt/certbot/certbot-auto renew --dry-run - -See full documentation and options on the [Certbot website](https://certbot.eff.org/). - -## License - -MIT / BSD - -## Author Information - -This role was created in 2016 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/roles/ansible-role-certbot/defaults/main.yml b/roles/ansible-role-certbot/defaults/main.yml deleted file mode 100644 index 7002b26..0000000 --- a/roles/ansible-role-certbot/defaults/main.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -# Certbot auto-renew cron job configuration (for certificate renewals). -certbot_auto_renew: true -certbot_auto_renew_user: "{{ ansible_user | default(lookup('env', 'USER')) }}" -certbot_auto_renew_hour: "3" -certbot_auto_renew_minute: "30" -certbot_auto_renew_options: "--quiet --no-self-upgrade" - -# Parameters used when creating new Certbot certs. -certbot_create_if_missing: false -certbot_create_method: standalone -certbot_admin_email: email@example.com -certbot_certs: [] -# - email: janedoe@example.com -# domains: -# - example1.com -# - example2.com -# - domains: -# - example3.com -certbot_create_command: >- - {{ certbot_script }} certonly --standalone --noninteractive --agree-tos - --email {{ cert_item.email | default(certbot_admin_email) }} - -d {{ cert_item.domains | join(',') }} - -certbot_create_standalone_stop_services: - - nginx - # - apache - # - varnish - -# To install from source (on older OSes or if you need a specific or newer -# version of Certbot), set this variable to `yes` and configure other options. -certbot_install_from_source: false -certbot_repo: https://github.com/certbot/certbot.git -certbot_version: master -certbot_keep_updated: true - -# Where to put Certbot when installing from source. -certbot_dir: /opt/certbot diff --git a/roles/ansible-role-certbot/meta/.galaxy_install_info b/roles/ansible-role-certbot/meta/.galaxy_install_info deleted file mode 100644 index 60e8e9a..0000000 --- a/roles/ansible-role-certbot/meta/.galaxy_install_info +++ /dev/null @@ -1,2 +0,0 @@ -install_date: Thu Oct 3 21:08:16 2019 -version: '' diff --git a/roles/ansible-role-certbot/meta/main.yml b/roles/ansible-role-certbot/meta/main.yml deleted file mode 100644 index e9b4a60..0000000 --- a/roles/ansible-role-certbot/meta/main.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependencies: [] - -galaxy_info: - author: geerlingguy - description: "Installs and configures Certbot (for Let's Encrypt)." - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 2.4 - platforms: - - name: EL - versions: - - 6 - - 7 - - name: Fedora - versions: - - all - - name: Ubuntu - versions: - - all - - name: Debian - versions: - - all - galaxy_tags: - - networking - - system - - web - - certbot - - letsencrypt - - encryption - - certificates - - ssl - - https diff --git a/roles/ansible-role-certbot/molecule/default/molecule.yml b/roles/ansible-role-certbot/molecule/default/molecule.yml deleted file mode 100644 index 2ca6fea..0000000 --- a/roles/ansible-role-certbot/molecule/default/molecule.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -lint: - name: yamllint - options: - config-file: molecule/default/yaml-lint.yml -platforms: - - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: true - pre_build_image: true -provisioner: - name: ansible - lint: - name: ansible-lint - playbooks: - converge: ${MOLECULE_PLAYBOOK:-playbook.yml} -scenario: - name: default -verifier: - name: testinfra - lint: - name: flake8 diff --git a/roles/ansible-role-certbot/molecule/default/playbook-source-install.yml b/roles/ansible-role-certbot/molecule/default/playbook-source-install.yml deleted file mode 100644 index 77ced51..0000000 --- a/roles/ansible-role-certbot/molecule/default/playbook-source-install.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- name: Converge - hosts: all - become: true - - vars: - certbot_install_from_source: true - certbot_auto_renew_user: root - - pre_tasks: - - name: Update apt cache. - apt: update_cache=yes cache_valid_time=600 - when: ansible_os_family == 'Debian' - changed_when: false - - - name: Install cron (RedHat). - yum: name=cronie state=present - when: ansible_os_family == 'RedHat' - - - name: Install cron (Debian). - apt: name=cron state=present - when: ansible_os_family == 'Debian' - - roles: - - geerlingguy.git - - geerlingguy.certbot diff --git a/roles/ansible-role-certbot/molecule/default/playbook-standalone-nginx-aws.yml b/roles/ansible-role-certbot/molecule/default/playbook-standalone-nginx-aws.yml deleted file mode 100644 index 481c688..0000000 --- a/roles/ansible-role-certbot/molecule/default/playbook-standalone-nginx-aws.yml +++ /dev/null @@ -1,179 +0,0 @@ ---- -# To run: -# 1. Ensure Ansible and Boto are installed (pip install ansible boto). -# 2. Ensure you have AWS credentials stored where Boto can find them, and they -# are under the profile 'mm'. -# 3. Ensure you have a pubkey available at ~/.ssh/id_rsa.pub. -# 3. Run the playbook: ansible-playbook test-standalone-nginx-aws.yml - -# Play 1: Provision EC2 instance and A record. -- hosts: localhost - connection: local - gather_facts: false - - tasks: - - name: Configure EC2 Security Group. - ec2_group: - profile: mm - name: certbot_test_http - description: HTTP security group for Certbot testing. - region: "us-east-1" - state: present - rules: - - proto: tcp - from_port: 80 - to_port: 80 - cidr_ip: 0.0.0.0/0 - - proto: tcp - from_port: 443 - to_port: 443 - cidr_ip: 0.0.0.0/0 - - proto: tcp - from_port: 22 - to_port: 22 - cidr_ip: 0.0.0.0/0 - rules_egress: [] - - - name: Add EC2 Key Pair. - ec2_key: - profile: mm - region: "us-east-1" - name: certbot_test - key_material: "{{ item }}" - with_file: ~/.ssh/id_rsa.pub - - - name: Provision EC2 instance. - ec2: - profile: mm - key_name: certbot_test - instance_tags: - Name: "certbot-standalone-nginx-test" - group: ['default', 'certbot_test_http'] - instance_type: t2.micro - # CentOS Linux 7 x86_64 HVM EBS - image: ami-02e98f78 - region: "us-east-1" - wait: true - wait_timeout: 500 - exact_count: 1 - count_tag: - Name: "certbot-standalone-nginx-test" - register: created_instance - - - name: Add A record for the new EC2 instance IP in Route53. - route53: - profile: mm - command: create - zone: servercheck.in - record: certbot-test.servercheck.in - type: A - ttl: 300 - value: "{{ created_instance.tagged_instances.0.public_ip }}" - wait: true - overwrite: true - - - name: Add EC2 instance to inventory groups. - add_host: - name: "certbot-test.servercheck.in" - groups: "aws,aws_nginx" - ansible_ssh_user: centos - host_key_checking: false - when: created_instance.tagged_instances.0.id is defined - -# Play 2: Configure EC2 instance with Certbot and Nginx. -- hosts: aws_nginx - gather_facts: true - become: true - - vars: - certbot_admin_email: https@servercheck.in - certbot_create_if_missing: true - certbot_create_standalone_stop_services: [] - certbot_certs: - - domains: - - certbot-test.servercheck.in - nginx_vhosts: - - listen: "443 ssl http2" - server_name: "certbot-test.servercheck.in" - root: "/usr/share/nginx/html" - index: "index.html index.htm" - state: "present" - template: "{{ nginx_vhost_template }}" - filename: "certbot_test.conf" - extra_parameters: | - ssl_certificate /etc/letsencrypt/live/certbot-test.servercheck.in/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/certbot-test.servercheck.in/privkey.pem; - ssl_protocols TLSv1.1 TLSv1.2; - ssl_ciphers HIGH:!aNULL:!MD5; - - pre_tasks: - - name: Update apt cache. - apt: update_cache=true cache_valid_time=600 - when: ansible_os_family == 'Debian' - changed_when: false - - - name: Install dependencies (RedHat). - yum: name={{ item }} state=present - when: ansible_os_family == 'RedHat' - with_items: - - cronie - - epel-release - - - name: Install cron (Debian). - apt: name=cron state=present - when: ansible_os_family == 'Debian' - - roles: - - geerlingguy.certbot - - geerlingguy.nginx - - tasks: - - name: Flush handlers in case any configs have changed. - meta: flush_handlers - - - name: Test secure connection to SSL domain. - uri: - url: https://certbot-test.servercheck.in/ - status_code: 200 - delegate_to: localhost - become: false - -# Play 3: Tear down EC2 instance and A record. -- hosts: localhost - connection: local - gather_facts: false - - tasks: - - name: Destroy EC2 instance. - ec2: - profile: mm - instance_ids: ["{{ created_instance.tagged_instances.0.id }}"] - region: "us-east-1" - state: absent - wait: true - wait_timeout: 500 - - - name: Delete Security Group. - ec2_group: - profile: mm - name: certbot_test_http - region: "us-east-1" - state: absent - - - name: Delete Key Pair. - ec2_key: - profile: mm - name: certbot_test - region: "us-east-1" - state: absent - - - name: Delete Route53 record. - route53: - profile: mm - state: delete - zone: servercheck.in - record: certbot-test.servercheck.in - type: A - ttl: 300 - # See: https://github.com/ansible/ansible/pull/32297 - value: [] diff --git a/roles/ansible-role-certbot/molecule/default/playbook.yml b/roles/ansible-role-certbot/molecule/default/playbook.yml deleted file mode 100644 index 9d6e5e7..0000000 --- a/roles/ansible-role-certbot/molecule/default/playbook.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Converge - hosts: all - become: true - - vars: - certbot_auto_renew_user: root - - pre_tasks: - - name: Update apt cache. - apt: update_cache=yes cache_valid_time=600 - when: ansible_os_family == 'Debian' - changed_when: false - - - name: Install dependencies (RedHat). - yum: name={{ item }} state=present - when: ansible_os_family == 'RedHat' - with_items: - - cronie - - epel-release - - - name: Install cron (Debian). - apt: name=cron state=present - when: ansible_os_family == 'Debian' - - roles: - - geerlingguy.certbot diff --git a/roles/ansible-role-certbot/molecule/default/requirements.yml b/roles/ansible-role-certbot/molecule/default/requirements.yml deleted file mode 100644 index 0b31312..0000000 --- a/roles/ansible-role-certbot/molecule/default/requirements.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- src: geerlingguy.git -- src: geerlingguy.nginx diff --git a/roles/ansible-role-certbot/molecule/default/yaml-lint.yml b/roles/ansible-role-certbot/molecule/default/yaml-lint.yml deleted file mode 100644 index a3dbc38..0000000 --- a/roles/ansible-role-certbot/molecule/default/yaml-lint.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -extends: default -rules: - line-length: - max: 120 - level: warning diff --git a/roles/ansible-role-certbot/tasks/create-cert-standalone.yml b/roles/ansible-role-certbot/tasks/create-cert-standalone.yml deleted file mode 100644 index 6f25b8a..0000000 --- a/roles/ansible-role-certbot/tasks/create-cert-standalone.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Check if certificate already exists. - stat: - path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem - register: letsencrypt_cert - -- name: Stop services to allow certbot to generate a cert. - service: - name: "{{ item }}" - state: stopped - when: not letsencrypt_cert.stat.exists - with_items: "{{ certbot_create_standalone_stop_services }}" - -- name: Generate new certificate if one doesn't exist. - command: "{{ certbot_create_command }}" - when: not letsencrypt_cert.stat.exists - -- name: Start services after cert has been generated. - service: - name: "{{ item }}" - state: started - when: not letsencrypt_cert.stat.exists - with_items: "{{ certbot_create_standalone_stop_services }}" diff --git a/roles/ansible-role-certbot/tasks/include-vars.yml b/roles/ansible-role-certbot/tasks/include-vars.yml deleted file mode 100644 index 0a70e50..0000000 --- a/roles/ansible-role-certbot/tasks/include-vars.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Load a variable file based on the OS type, or a default if not found. - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml" - - "{{ ansible_distribution }}.yml" - - "{{ ansible_os_family }}.yml" - - "default.yml" diff --git a/roles/ansible-role-certbot/tasks/install-from-source.yml b/roles/ansible-role-certbot/tasks/install-from-source.yml deleted file mode 100644 index daee685..0000000 --- a/roles/ansible-role-certbot/tasks/install-from-source.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- name: Clone Certbot into configured directory. - git: - repo: "{{ certbot_repo }}" - dest: "{{ certbot_dir }}" - version: "{{ certbot_version }}" - update: "{{ certbot_keep_updated }}" - force: true - -- name: Set Certbot script variable. - set_fact: - certbot_script: "{{ certbot_dir }}/certbot-auto" - -- name: Ensure certbot-auto is executable. - file: - path: "{{ certbot_script }}" - mode: 0755 diff --git a/roles/ansible-role-certbot/tasks/install-with-package.yml b/roles/ansible-role-certbot/tasks/install-with-package.yml deleted file mode 100644 index 10490ff..0000000 --- a/roles/ansible-role-certbot/tasks/install-with-package.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Install Certbot. - package: "name={{ certbot_package }} state=present" - -- name: Set Certbot script variable. - set_fact: - certbot_script: "{{ certbot_package }}" diff --git a/roles/ansible-role-certbot/tasks/main.yml b/roles/ansible-role-certbot/tasks/main.yml deleted file mode 100644 index 680aeda..0000000 --- a/roles/ansible-role-certbot/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- import_tasks: include-vars.yml - -- import_tasks: install-with-package.yml - when: not certbot_install_from_source - -- import_tasks: install-from-source.yml - when: certbot_install_from_source - -- include_tasks: create-cert-standalone.yml - with_items: "{{ certbot_certs }}" - when: - - certbot_create_if_missing - - certbot_create_method == 'standalone' - loop_control: - loop_var: cert_item - -- import_tasks: renew-cron.yml - when: certbot_auto_renew diff --git a/roles/ansible-role-certbot/tasks/renew-cron.yml b/roles/ansible-role-certbot/tasks/renew-cron.yml deleted file mode 100644 index 394a30e..0000000 --- a/roles/ansible-role-certbot/tasks/renew-cron.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Add cron job for certbot renewal (if configured). - cron: - name: Certbot automatic renewal. - job: "{{ certbot_script }} renew {{ certbot_auto_renew_options }}" - minute: "{{ certbot_auto_renew_minute }}" - hour: "{{ certbot_auto_renew_hour }}" - user: "{{ certbot_auto_renew_user }}" diff --git a/roles/ansible-role-certbot/vars/Ubuntu-16.04.yml b/roles/ansible-role-certbot/vars/Ubuntu-16.04.yml deleted file mode 100644 index 83cf124..0000000 --- a/roles/ansible-role-certbot/vars/Ubuntu-16.04.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -certbot_package: letsencrypt diff --git a/roles/ansible-role-certbot/vars/default.yml b/roles/ansible-role-certbot/vars/default.yml deleted file mode 100644 index d88f2dc..0000000 --- a/roles/ansible-role-certbot/vars/default.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -certbot_package: certbot diff --git a/roles/geerlingguy.pip/.gitignore b/roles/geerlingguy.pip/.gitignore deleted file mode 100644 index f56f5b5..0000000 --- a/roles/geerlingguy.pip/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.retry -*/__pycache__ -*.pyc diff --git a/roles/geerlingguy.pip/.travis.yml b/roles/geerlingguy.pip/.travis.yml deleted file mode 100644 index 906b30d..0000000 --- a/roles/geerlingguy.pip/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -services: docker - -env: - global: - - ROLE_NAME: pip - matrix: - - MOLECULE_DISTRO: centos7 - - MOLECULE_DISTRO: fedora29 - - MOLECULE_DISTRO: ubuntu1804 - - MOLECULE_DISTRO: debian9 - -install: - # Install test dependencies. - - pip install molecule docker - -before_script: - # Use actual Ansible Galaxy role name for the project directory. - - cd ../ - - mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME - - cd geerlingguy.$ROLE_NAME - -script: - # Run tests. - - molecule test - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/geerlingguy.pip/LICENSE b/roles/geerlingguy.pip/LICENSE deleted file mode 100644 index 4275cf3..0000000 --- a/roles/geerlingguy.pip/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Jeff Geerling - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/roles/geerlingguy.pip/README.md b/roles/geerlingguy.pip/README.md deleted file mode 100644 index ec9beb9..0000000 --- a/roles/geerlingguy.pip/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# Ansible Role: Pip (for Python) - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-pip.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-pip) - -An Ansible Role that installs [Pip](https://pip.pypa.io) on Linux. - -## Requirements - -On RedHat/CentOS, you may need to have EPEL installed before running this role. You can use the `geerlingguy.repo-epel` role if you need a simple way to ensure it's installed. - -## Role Variables - -Available variables are listed below, along with default values (see `defaults/main.yml`): - - pip_package: python-pip - -The name of the packge to install to get `pip` on the system. You can set to `python3-pip`, for example, when using Python 3 on Ubuntu. - - pip_executable: pip - -The role will try to autodetect the pip executable based on the `pip_package` (e.g. `pip` for Python 2 and `pip3` for Python 3). You can also override this explicitly, e.g. `pip_executable: pip3.6`. - - pip_install_packages: [] - -A list of packages to install with pip. Examples below: - - pip_install_packages: - # Specify names and versions. - - name: docker - version: "1.2.3" - - name: awscli - version: "1.11.91" - - # Or specify bare packages to get the latest release. - - docker - - awscli - - # Or uninstall a package. - - name: docker - state: absent - - # Or update a package ot the latest version. - - name: docker - state: latest - - # Or force a reinstall. - - name: docker - state: forcereinstall - - # Or install a package in a particular virtualenv. - - name: docker - virtualenv: /my_app/venv - -## Dependencies - -None. - -## Example Playbook - - - hosts: all - - vars: - pip_install_packages: - - name: docker - - name: awscli - - roles: - - geerlingguy.pip - -## License - -MIT / BSD - -## Author Information - -This role was created in 2017 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/roles/geerlingguy.pip/defaults/main.yml b/roles/geerlingguy.pip/defaults/main.yml deleted file mode 100644 index 8a70a1e..0000000 --- a/roles/geerlingguy.pip/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# For Python 3, use python3-pip. -pip_package: python-pip -pip_executable: "{{ 'pip3' if pip_package.startswith('python3') else 'pip' }}" - -pip_install_packages: [] diff --git a/roles/geerlingguy.pip/meta/.galaxy_install_info b/roles/geerlingguy.pip/meta/.galaxy_install_info deleted file mode 100644 index 430bcb1..0000000 --- a/roles/geerlingguy.pip/meta/.galaxy_install_info +++ /dev/null @@ -1,2 +0,0 @@ -install_date: Tue Sep 24 09:13:41 2019 -version: 1.3.0 diff --git a/roles/geerlingguy.pip/meta/main.yml b/roles/geerlingguy.pip/meta/main.yml deleted file mode 100644 index eb4248b..0000000 --- a/roles/geerlingguy.pip/meta/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -dependencies: [] - -galaxy_info: - author: geerlingguy - description: Pip (Python package manager) for Linux. - issue_tracker_url: https://github.com/geerlingguy/ansible-role-pip/issues - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 2.0 - platforms: - - name: EL - versions: - - all - - name: Fedora - versions: - - all - - name: Debian - versions: - - all - - name: Ubuntu - versions: - - all - galaxy_tags: - - system - - server - - packaging - - python - - pip - - tools diff --git a/roles/geerlingguy.pip/molecule/default/molecule.yml b/roles/geerlingguy.pip/molecule/default/molecule.yml deleted file mode 100644 index 2ca6fea..0000000 --- a/roles/geerlingguy.pip/molecule/default/molecule.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -lint: - name: yamllint - options: - config-file: molecule/default/yaml-lint.yml -platforms: - - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: true - pre_build_image: true -provisioner: - name: ansible - lint: - name: ansible-lint - playbooks: - converge: ${MOLECULE_PLAYBOOK:-playbook.yml} -scenario: - name: default -verifier: - name: testinfra - lint: - name: flake8 diff --git a/roles/geerlingguy.pip/molecule/default/playbook.yml b/roles/geerlingguy.pip/molecule/default/playbook.yml deleted file mode 100644 index 6ffa90b..0000000 --- a/roles/geerlingguy.pip/molecule/default/playbook.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: Converge - hosts: all - become: true - - vars: - pip_install_packages: - # Test installing a specific version of a package. - - name: ipaddress - version: "1.0.18" - # Test installing a package by name. - - colorama - - pre_tasks: - - name: Update apt cache. - apt: update_cache=true cache_valid_time=600 - when: ansible_os_family == 'Debian' - - roles: - - role: geerlingguy.pip diff --git a/roles/geerlingguy.pip/molecule/default/tests/test_default.py b/roles/geerlingguy.pip/molecule/default/tests/test_default.py deleted file mode 100644 index eedd64a..0000000 --- a/roles/geerlingguy.pip/molecule/default/tests/test_default.py +++ /dev/null @@ -1,14 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -def test_hosts_file(host): - f = host.file('/etc/hosts') - - assert f.exists - assert f.user == 'root' - assert f.group == 'root' diff --git a/roles/geerlingguy.pip/molecule/default/yaml-lint.yml b/roles/geerlingguy.pip/molecule/default/yaml-lint.yml deleted file mode 100644 index a3dbc38..0000000 --- a/roles/geerlingguy.pip/molecule/default/yaml-lint.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -extends: default -rules: - line-length: - max: 120 - level: warning diff --git a/roles/geerlingguy.pip/tasks/main.yml b/roles/geerlingguy.pip/tasks/main.yml deleted file mode 100644 index dda7fac..0000000 --- a/roles/geerlingguy.pip/tasks/main.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Ensure Pip is installed. - package: - name: "{{ pip_package }}" - state: present - -- name: Ensure pip_install_packages are installed. - pip: - name: "{{ item.name | default(item) }}" - version: "{{ item.version | default(omit) }}" - virtualenv: "{{ item.virtualenv | default(omit) }}" - state: "{{ item.state | default(omit) }}" - executable: "{{ pip_executable }}" - with_items: "{{ pip_install_packages }}" diff --git a/roles/geerlingguy.postgresql/.ansible-lint b/roles/geerlingguy.postgresql/.ansible-lint deleted file mode 100644 index f3c1090..0000000 --- a/roles/geerlingguy.postgresql/.ansible-lint +++ /dev/null @@ -1,3 +0,0 @@ -skip_list: - - '405' - - '503' diff --git a/roles/geerlingguy.postgresql/.gitignore b/roles/geerlingguy.postgresql/.gitignore deleted file mode 100644 index f56f5b5..0000000 --- a/roles/geerlingguy.postgresql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.retry -*/__pycache__ -*.pyc diff --git a/roles/geerlingguy.postgresql/.travis.yml b/roles/geerlingguy.postgresql/.travis.yml deleted file mode 100644 index 7aab231..0000000 --- a/roles/geerlingguy.postgresql/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -language: python -services: docker - -env: - global: - - ROLE_NAME: postgresql - matrix: - - MOLECULE_DISTRO: centos7 - - MOLECULE_DISTRO: fedora30 - - MOLECULE_DISTRO: ubuntu1804 - - MOLECULE_DISTRO: ubuntu1604 - - MOLECULE_DISTRO: debian10 - - MOLECULE_DISTRO: debian9 - -install: - # Install test dependencies. - - pip install molecule docker - -before_script: - # Use actual Ansible Galaxy role name for the project directory. - - cd ../ - - mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME - - cd geerlingguy.$ROLE_NAME - -script: - # Run tests. - - molecule test - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/geerlingguy.postgresql/LICENSE b/roles/geerlingguy.postgresql/LICENSE deleted file mode 100644 index 4275cf3..0000000 --- a/roles/geerlingguy.postgresql/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Jeff Geerling - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/roles/geerlingguy.postgresql/README.md b/roles/geerlingguy.postgresql/README.md deleted file mode 100644 index 6d81e4e..0000000 --- a/roles/geerlingguy.postgresql/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# Ansible Role: PostgreSQL - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-postgresql.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-postgresql) - -Installs and configures PostgreSQL server on RHEL/CentOS or Debian/Ubuntu servers. - -## Requirements - -No special requirements; note that this role requires root access, so either run it in a playbook with a global `become: yes`, or invoke the role in your playbook like: - - - hosts: database - roles: - - role: geerlingguy.postgresql - become: yes - -## Role Variables - -Available variables are listed below, along with default values (see `defaults/main.yml`): - - postgresql_enablerepo: "" - -(RHEL/CentOS only) You can set a repo to use for the PostgreSQL installation by passing it in here. - - postgresql_restarted_state: "restarted" - -Set the state of the service when configuration changes are made. Recommended values are `restarted` or `reloaded`. - - postgresql_python_library: python-psycopg2 - -Library used by Ansible to communicate with PostgreSQL. If you are using Python 3 (e.g. set via `ansible_python_interpreter`), you should change this to `python3-psycopg2`. - - postgresql_user: postgres - postgresql_group: postgres - -The user and group under which PostgreSQL will run. - - postgresql_unix_socket_directories: - - /var/run/postgresql - -The directories (usually one, but can be multiple) where PostgreSQL's socket will be created. - - postgresql_service_state: started - postgresql_service_enabled: true - -Control the state of the postgresql service and whether it should start at boot time. - - postgresql_global_config_options: - - option: unix_socket_directories - value: '{{ postgresql_unix_socket_directories | join(",") }}' - -Global configuration options that will be set in `postgresql.conf`. Note that for RHEL/CentOS 6 (or very old versions of PostgreSQL), you need to at least override this variable and set the `option` to `unix_socket_directory`. - - postgresql_hba_entries: - - { type: local, database: all, user: postgres, auth_method: peer } - - { type: local, database: all, user: all, auth_method: peer } - - { type: host, database: all, user: all, address: '127.0.0.1/32', auth_method: md5 } - - { type: host, database: all, user: all, address: '::1/128', auth_method: md5 } - -Configure [host based authentication](https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html) entries to be set in the `pg_hba.conf`. Options for entries include: - - - `type` (required) - - `database` (required) - - `user` (required) - - `address` (one of this or the following two are required) - - `ip_address` - - `ip_mask` - - `auth_method` (required) - - `auth_options` (optional) - -If overriding, make sure you copy all of the existing entries from `defaults/main.yml` if you need to preserve existing entries. - - postgresql_locales: - - 'en_US.UTF-8' - -(Debian/Ubuntu only) Used to generate the locales used by PostgreSQL databases. - - postgresql_databases: - - name: exampledb # required; the rest are optional - lc_collate: # defaults to 'en_US.UTF-8' - lc_ctype: # defaults to 'en_US.UTF-8' - encoding: # defaults to 'UTF-8' - template: # defaults to 'template0' - login_host: # defaults to 'localhost' - login_password: # defaults to not set - login_user: # defaults to 'postgresql_user' - login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories - port: # defaults to not set - owner: # defaults to postgresql_user - state: # defaults to 'present' - -A list of databases to ensure exist on the server. Only the `name` is required; all other properties are optional. - - postgresql_users: - - name: jdoe #required; the rest are optional - password: # defaults to not set - encrypted: # defaults to not set - priv: # defaults to not set - role_attr_flags: # defaults to not set - db: # defaults to not set - login_host: # defaults to 'localhost' - login_password: # defaults to not set - login_user: # defaults to '{{ postgresql_user }}' - login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories - port: # defaults to not set - state: # defaults to 'present' - -A list of users to ensure exist on the server. Only the `name` is required; all other properties are optional. - - postgresql_version: [OS-specific] - postgresql_data_dir: [OS-specific] - postgresql_bin_path: [OS-specific] - postgresql_config_path: [OS-specific] - postgresql_daemon: [OS-specific] - postgresql_packages: [OS-specific] - -OS-specific variables that are set by include files in this role's `vars` directory. These shouldn't be overridden unless you're using a version of PostgreSQL that wasn't installed using system packages. - -## Dependencies - -None. - -## Example Playbook - - - hosts: database - become: yes - vars_files: - - vars/main.yml - roles: - - geerlingguy.postgresql - -*Inside `vars/main.yml`*: - - postgresql_databases: - - name: example_db - postgresql_users: - - name: example_user - password: supersecure - -## License - -MIT / BSD - -## Author Information - -This role was created in 2016 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/roles/geerlingguy.postgresql/defaults/main.yml b/roles/geerlingguy.postgresql/defaults/main.yml deleted file mode 100644 index fa6a87f..0000000 --- a/roles/geerlingguy.postgresql/defaults/main.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -# RHEL/CentOS only. Set a repository to use for PostgreSQL installation. -postgresql_enablerepo: "" - -# Set postgresql state when configuration changes are made. Recommended values: -# `restarted` or `reloaded` -postgresql_restarted_state: "restarted" - -postgresql_python_library: python-psycopg2 -postgresql_user: postgres -postgresql_group: postgres - -postgresql_unix_socket_directories: - - /var/run/postgresql - -postgresql_service_state: started -postgresql_service_enabled: true - -# Global configuration options that will be set in postgresql.conf. -postgresql_global_config_options: - - option: unix_socket_directories - value: '{{ postgresql_unix_socket_directories | join(",") }}' - -# Host based authentication (hba) entries to be added to the pg_hba.conf. This -# variable's defaults reflect the defaults that come with a fresh installation. -postgresql_hba_entries: - - {type: local, database: all, user: postgres, auth_method: peer} - - {type: local, database: all, user: all, auth_method: peer} - - {type: host, database: all, user: all, address: '127.0.0.1/32', auth_method: md5} - - {type: host, database: all, user: all, address: '::1/128', auth_method: md5} - -# Debian only. Used to generate the locales used by PostgreSQL databases. -postgresql_locales: - - 'en_US.UTF-8' - -# Databases to ensure exist. -postgresql_databases: [] -# - name: exampledb # required; the rest are optional -# lc_collate: # defaults to 'en_US.UTF-8' -# lc_ctype: # defaults to 'en_US.UTF-8' -# encoding: # defaults to 'UTF-8' -# template: # defaults to 'template0' -# login_host: # defaults to 'localhost' -# login_password: # defaults to not set -# login_user: # defaults to '{{ postgresql_user }}' -# login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories -# port: # defaults to not set -# owner: # defaults to postgresql_user -# state: # defaults to 'present' - -# Users to ensure exist. -postgresql_users: [] -# - name: jdoe #required; the rest are optional -# password: # defaults to not set -# encrypted: # defaults to not set -# priv: # defaults to not set -# role_attr_flags: # defaults to not set -# db: # defaults to not set -# login_host: # defaults to 'localhost' -# login_password: # defaults to not set -# login_user: # defaults to '{{ postgresql_user }}' -# login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories -# port: # defaults to not set -# state: # defaults to 'present' diff --git a/roles/geerlingguy.postgresql/handlers/main.yml b/roles/geerlingguy.postgresql/handlers/main.yml deleted file mode 100644 index cce42b7..0000000 --- a/roles/geerlingguy.postgresql/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: restart postgresql - service: - name: "{{ postgresql_daemon }}" - state: "{{ postgresql_restarted_state }}" - sleep: 5 diff --git a/roles/geerlingguy.postgresql/meta/.galaxy_install_info b/roles/geerlingguy.postgresql/meta/.galaxy_install_info deleted file mode 100644 index bd7ee9b..0000000 --- a/roles/geerlingguy.postgresql/meta/.galaxy_install_info +++ /dev/null @@ -1,2 +0,0 @@ -install_date: Tue Sep 24 09:13:46 2019 -version: 2.0.0 diff --git a/roles/geerlingguy.postgresql/meta/main.yml b/roles/geerlingguy.postgresql/meta/main.yml deleted file mode 100644 index 2c962a6..0000000 --- a/roles/geerlingguy.postgresql/meta/main.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependencies: [] - -galaxy_info: - author: geerlingguy - description: PostgreSQL server for Linux. - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 2.4 - platforms: - - name: EL - versions: - - 6 - - 7 - - name: Fedora - versions: - - 29 - - 30 - - name: Ubuntu - versions: - - xenial - - bionic - - name: Debian - versions: - - wheezy - - jessie - - stretch - - buster - galaxy_tags: - - database - - postgresql - - postgres - - rdbms diff --git a/roles/geerlingguy.postgresql/molecule/default/molecule.yml b/roles/geerlingguy.postgresql/molecule/default/molecule.yml deleted file mode 100644 index 2ca6fea..0000000 --- a/roles/geerlingguy.postgresql/molecule/default/molecule.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -lint: - name: yamllint - options: - config-file: molecule/default/yaml-lint.yml -platforms: - - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: true - pre_build_image: true -provisioner: - name: ansible - lint: - name: ansible-lint - playbooks: - converge: ${MOLECULE_PLAYBOOK:-playbook.yml} -scenario: - name: default -verifier: - name: testinfra - lint: - name: flake8 diff --git a/roles/geerlingguy.postgresql/molecule/default/playbook.yml b/roles/geerlingguy.postgresql/molecule/default/playbook.yml deleted file mode 100644 index a437c51..0000000 --- a/roles/geerlingguy.postgresql/molecule/default/playbook.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- name: Converge - hosts: all - become: true - - vars: - postgresql_databases: - - name: example - postgresql_users: - - name: jdoe - - pre_tasks: - # The Fedora 30+ container images have only C.UTF-8 installed - - name: Set database locale if using Fedora 30+ - set_fact: - postgresql_databases: - - name: example - lc_collate: 'C.UTF-8' - lc_ctype: 'C.UTF-8' - when: - - ansible_distribution == 'Fedora' - - ansible_distribution_major_version >= '30' - - - name: Update apt cache. - apt: update_cache=true cache_valid_time=600 - when: ansible_os_family == 'Debian' - - - name: Set custom variables for old CentOS 6 PostgreSQL install. - set_fact: - postgresql_hba_entries: [] - postgresql_global_config_options: - - option: unix_socket_directory - value: '{{ postgresql_unix_socket_directories[0] }}' - when: - - ansible_os_family == 'RedHat' - - ansible_distribution_version.split('.')[0] == '6' - - roles: - - role: geerlingguy.postgresql - - post_tasks: - - name: Verify postgres is running. - command: "{{ postgresql_bin_path }}/pg_ctl -D {{ postgresql_data_dir }} status" - changed_when: false - become: true - become_user: postgres diff --git a/roles/geerlingguy.postgresql/molecule/default/yaml-lint.yml b/roles/geerlingguy.postgresql/molecule/default/yaml-lint.yml deleted file mode 100644 index a3dbc38..0000000 --- a/roles/geerlingguy.postgresql/molecule/default/yaml-lint.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -extends: default -rules: - line-length: - max: 120 - level: warning diff --git a/roles/geerlingguy.postgresql/tasks/configure.yml b/roles/geerlingguy.postgresql/tasks/configure.yml deleted file mode 100644 index 28504a5..0000000 --- a/roles/geerlingguy.postgresql/tasks/configure.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Configure global settings. - lineinfile: - dest: "{{ postgresql_config_path }}/postgresql.conf" - regexp: "^#?{{ item.option }}.+$" - line: "{{ item.option }} = '{{ item.value }}'" - state: "{{ item.state | default('present') }}" - with_items: "{{ postgresql_global_config_options }}" - notify: restart postgresql - -- name: Configure host based authentication (if entries are configured). - template: - src: "pg_hba.conf.j2" - dest: "{{ postgresql_config_path }}/pg_hba.conf" - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" - mode: 0600 - notify: restart postgresql - when: postgresql_hba_entries | length > 0 - -- name: Ensure PostgreSQL unix socket dirs exist. - file: - path: "{{ item }}" - state: directory - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" - mode: 02775 - with_items: "{{ postgresql_unix_socket_directories }}" diff --git a/roles/geerlingguy.postgresql/tasks/databases.yml b/roles/geerlingguy.postgresql/tasks/databases.yml deleted file mode 100644 index e01d804..0000000 --- a/roles/geerlingguy.postgresql/tasks/databases.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Ensure PostgreSQL databases are present. - postgresql_db: - name: "{{ item.name }}" - lc_collate: "{{ item.lc_collate | default('en_US.UTF-8') }}" - lc_ctype: "{{ item.lc_ctype | default('en_US.UTF-8') }}" - encoding: "{{ item.encoding | default('UTF-8') }}" - template: "{{ item.template | default('template0') }}" - login_host: "{{ item.login_host | default('localhost') }}" - login_password: "{{ item.login_password | default(omit) }}" - login_user: "{{ item.login_user | default(postgresql_user) }}" - login_unix_socket: "{{ item.login_unix_socket | default(postgresql_unix_socket_directories[0]) }}" - port: "{{ item.port | default(omit) }}" - owner: "{{ item.owner | default(postgresql_user) }}" - state: "{{ item.state | default('present') }}" - with_items: "{{ postgresql_databases }}" - become: true - become_user: "{{ postgresql_user }}" - # See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509 - vars: - ansible_ssh_pipelining: true diff --git a/roles/geerlingguy.postgresql/tasks/initialize.yml b/roles/geerlingguy.postgresql/tasks/initialize.yml deleted file mode 100644 index 0183121..0000000 --- a/roles/geerlingguy.postgresql/tasks/initialize.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- name: Set PostgreSQL environment variables. - template: - src: postgres.sh.j2 - dest: /etc/profile.d/postgres.sh - mode: 0644 - notify: restart postgresql - -- name: Ensure PostgreSQL data directory exists. - file: - path: "{{ postgresql_data_dir }}" - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" - state: directory - mode: 0700 - -- name: Check if PostgreSQL database is initialized. - stat: - path: "{{ postgresql_data_dir }}/PG_VERSION" - register: pgdata_dir_version - -- name: Ensure PostgreSQL database is initialized. - command: "{{ postgresql_bin_path }}/initdb -D {{ postgresql_data_dir }}" - when: not pgdata_dir_version.stat.exists - become: true - become_user: "{{ postgresql_user }}" - # See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509 - vars: - ansible_ssh_pipelining: true diff --git a/roles/geerlingguy.postgresql/tasks/main.yml b/roles/geerlingguy.postgresql/tasks/main.yml deleted file mode 100644 index 5d4f5fe..0000000 --- a/roles/geerlingguy.postgresql/tasks/main.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# Variable configuration. -- include_tasks: variables.yml - -# Setup/install tasks. -- include_tasks: setup-RedHat.yml - when: ansible_os_family == 'RedHat' - -- include_tasks: setup-Debian.yml - when: ansible_os_family == 'Debian' - -- include_tasks: initialize.yml -- include_tasks: configure.yml - -- name: Ensure PostgreSQL is started and enabled on boot. - service: - name: "{{ postgresql_daemon }}" - state: "{{ postgresql_service_state }}" - enabled: "{{ postgresql_service_enabled }}" - -# Configure PostgreSQL. -- import_tasks: users.yml -- import_tasks: databases.yml diff --git a/roles/geerlingguy.postgresql/tasks/setup-Debian.yml b/roles/geerlingguy.postgresql/tasks/setup-Debian.yml deleted file mode 100644 index 1b54019..0000000 --- a/roles/geerlingguy.postgresql/tasks/setup-Debian.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Ensure PostgreSQL Python libraries are installed. - apt: - name: "{{ postgresql_python_library }}" - state: present - -- name: Ensure PostgreSQL packages are installed. - apt: - name: "{{ postgresql_packages }}" - state: present - -- name: Ensure all configured locales are present. - locale_gen: "name={{ item }} state=present" - with_items: "{{ postgresql_locales }}" - register: locale_gen_result - -- name: Force-restart PostgreSQL after new locales are generated. - service: - name: "{{ postgresql_daemon }}" - state: restarted - when: locale_gen_result.changed diff --git a/roles/geerlingguy.postgresql/tasks/setup-RedHat.yml b/roles/geerlingguy.postgresql/tasks/setup-RedHat.yml deleted file mode 100644 index d536bcb..0000000 --- a/roles/geerlingguy.postgresql/tasks/setup-RedHat.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Ensure PostgreSQL packages are installed. - yum: - name: "{{ postgresql_packages }}" - state: present - enablerepo: "{{ postgresql_enablerepo | default(omit, true) }}" - # Don't let postgresql-contrib cause the /usr/bin/python symlink - # to be installed, which breaks later Ansible runs on Fedora 30, - # and affects system behavior in multiple ways. - exclude: python-unversioned-command - -- name: Ensure PostgreSQL Python libraries are installed. - yum: - name: "{{ postgresql_python_library }}" - state: present - enablerepo: "{{ postgresql_enablerepo | default(omit, true) }}" diff --git a/roles/geerlingguy.postgresql/tasks/users.yml b/roles/geerlingguy.postgresql/tasks/users.yml deleted file mode 100644 index 77f1e4f..0000000 --- a/roles/geerlingguy.postgresql/tasks/users.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Ensure PostgreSQL users are present. - postgresql_user: - name: "{{ item.name }}" - password: "{{ item.password | default(omit) }}" - encrypted: "{{ item.encrypted | default(omit) }}" - priv: "{{ item.priv | default(omit) }}" - role_attr_flags: "{{ item.role_attr_flags | default(omit) }}" - db: "{{ item.db | default(omit) }}" - login_host: "{{ item.login_host | default('localhost') }}" - login_password: "{{ item.login_password | default(omit) }}" - login_user: "{{ item.login_user | default(postgresql_user) }}" - login_unix_socket: "{{ item.login_unix_socket | default(postgresql_unix_socket_directories[0]) }}" - port: "{{ item.port | default(omit) }}" - state: "{{ item.state | default('present') }}" - with_items: "{{ postgresql_users }}" - # no_log: true - become: true - become_user: "{{ postgresql_user }}" - # See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509 - vars: - ansible_ssh_pipelining: true diff --git a/roles/geerlingguy.postgresql/tasks/variables.yml b/roles/geerlingguy.postgresql/tasks/variables.yml deleted file mode 100644 index 7f45154..0000000 --- a/roles/geerlingguy.postgresql/tasks/variables.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -# Variable configuration. -- name: Include OS-specific variables (Debian). - include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - when: ansible_os_family == 'Debian' - -- name: Include OS-specific variables (RedHat). - include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - when: - - ansible_os_family == 'RedHat' - - ansible_distribution != 'Fedora' - -- name: Include OS-specific variables (Fedora). - include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - when: ansible_distribution == 'Fedora' - -- name: Define postgresql_packages. - set_fact: - postgresql_packages: "{{ __postgresql_packages | list }}" - when: postgresql_packages is not defined - -- name: Define postgresql_version. - set_fact: - postgresql_version: "{{ __postgresql_version }}" - when: postgresql_version is not defined - -- name: Define postgresql_daemon. - set_fact: - postgresql_daemon: "{{ __postgresql_daemon }}" - when: postgresql_daemon is not defined - -- name: Define postgresql_data_dir. - set_fact: - postgresql_data_dir: "{{ __postgresql_data_dir }}" - when: postgresql_data_dir is not defined - -- name: Define postgresql_bin_path. - set_fact: - postgresql_bin_path: "{{ __postgresql_bin_path }}" - when: postgresql_bin_path is not defined - -- name: Define postgresql_config_path. - set_fact: - postgresql_config_path: "{{ __postgresql_config_path }}" - when: postgresql_config_path is not defined diff --git a/roles/geerlingguy.postgresql/templates/pg_hba.conf.j2 b/roles/geerlingguy.postgresql/templates/pg_hba.conf.j2 deleted file mode 100644 index 05cc8a0..0000000 --- a/roles/geerlingguy.postgresql/templates/pg_hba.conf.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{{ ansible_managed | comment }} -# PostgreSQL Client Authentication Configuration File -# =================================================== -# -# See: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html - -{% for client in postgresql_hba_entries %} -{{ client.type }} {{ client.database }} {{ client.user }} {{ client.address|default('') }} {{ client.ip_address|default('') }} {{ client.ip_mask|default('') }} {{ client.auth_method }} {{ client.auth_options|default("") }} -{% endfor %} diff --git a/roles/geerlingguy.postgresql/templates/postgres.sh.j2 b/roles/geerlingguy.postgresql/templates/postgres.sh.j2 deleted file mode 100644 index 7264064..0000000 --- a/roles/geerlingguy.postgresql/templates/postgres.sh.j2 +++ /dev/null @@ -1,2 +0,0 @@ -export PGDATA={{ postgresql_data_dir }} -export PATH=$PATH:{{ postgresql_bin_path }} diff --git a/roles/geerlingguy.postgresql/vars/Debian-10.yml b/roles/geerlingguy.postgresql/vars/Debian-10.yml deleted file mode 100644 index fe81ad7..0000000 --- a/roles/geerlingguy.postgresql/vars/Debian-10.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -__postgresql_version: "11" -__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" -__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" -__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" -__postgresql_daemon: "postgresql@{{ postgresql_version }}-main" -__postgresql_packages: - - postgresql - - postgresql-contrib - - libpq-dev diff --git a/roles/geerlingguy.postgresql/vars/Debian-7.yml b/roles/geerlingguy.postgresql/vars/Debian-7.yml deleted file mode 100644 index 6b933bb..0000000 --- a/roles/geerlingguy.postgresql/vars/Debian-7.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -__postgresql_version: "9.1" -__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" -__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" -__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-contrib - - libpq-dev diff --git a/roles/geerlingguy.postgresql/vars/Debian-8.yml b/roles/geerlingguy.postgresql/vars/Debian-8.yml deleted file mode 100644 index ec86f93..0000000 --- a/roles/geerlingguy.postgresql/vars/Debian-8.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -__postgresql_version: "9.4" -__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" -__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" -__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" -__postgresql_daemon: "postgresql@{{ postgresql_version }}-main" -__postgresql_packages: - - postgresql - - postgresql-contrib - - libpq-dev diff --git a/roles/geerlingguy.postgresql/vars/Debian-9.yml b/roles/geerlingguy.postgresql/vars/Debian-9.yml deleted file mode 100644 index 2afb9f4..0000000 --- a/roles/geerlingguy.postgresql/vars/Debian-9.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -__postgresql_version: "9.6" -__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" -__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" -__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" -__postgresql_daemon: "postgresql@{{ postgresql_version }}-main" -__postgresql_packages: - - postgresql - - postgresql-contrib - - libpq-dev diff --git a/roles/geerlingguy.postgresql/vars/Fedora-29.yml b/roles/geerlingguy.postgresql/vars/Fedora-29.yml deleted file mode 100644 index 4e09932..0000000 --- a/roles/geerlingguy.postgresql/vars/Fedora-29.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -__postgresql_version: "10.5" -__postgresql_data_dir: "/var/lib/pgsql/data" -__postgresql_bin_path: "/usr/bin" -__postgresql_config_path: "/var/lib/pgsql/data" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-server - - postgresql-contrib - - postgresql-libs -postgresql_python_library: python2-psycopg2 diff --git a/roles/geerlingguy.postgresql/vars/Fedora-30.yml b/roles/geerlingguy.postgresql/vars/Fedora-30.yml deleted file mode 100644 index d07f14b..0000000 --- a/roles/geerlingguy.postgresql/vars/Fedora-30.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -__postgresql_version: "11.2" -__postgresql_data_dir: "/var/lib/pgsql/data" -__postgresql_bin_path: "/usr/bin" -__postgresql_config_path: "/var/lib/pgsql/data" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-server - - postgresql-contrib - - postgresql-libs -# Fedora 30 containers only have python3 by default -postgresql_python_library: python3-psycopg2 diff --git a/roles/geerlingguy.postgresql/vars/RedHat-6.yml b/roles/geerlingguy.postgresql/vars/RedHat-6.yml deleted file mode 100644 index 8923c50..0000000 --- a/roles/geerlingguy.postgresql/vars/RedHat-6.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -__postgresql_version: "8.4" -__postgresql_data_dir: "/var/lib/pgsql/data" -__postgresql_bin_path: "/usr/bin" -__postgresql_config_path: "/var/lib/pgsql/data" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-server - - postgresql-contrib - - postgresql-libs diff --git a/roles/geerlingguy.postgresql/vars/RedHat-7.yml b/roles/geerlingguy.postgresql/vars/RedHat-7.yml deleted file mode 100644 index 1d5c517..0000000 --- a/roles/geerlingguy.postgresql/vars/RedHat-7.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -__postgresql_version: "9.2" -__postgresql_data_dir: "/var/lib/pgsql/data" -__postgresql_bin_path: "/usr/bin" -__postgresql_config_path: "/var/lib/pgsql/data" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-server - - postgresql-contrib - - postgresql-libs diff --git a/roles/geerlingguy.postgresql/vars/Ubuntu-16.yml b/roles/geerlingguy.postgresql/vars/Ubuntu-16.yml deleted file mode 100644 index cf2ebb8..0000000 --- a/roles/geerlingguy.postgresql/vars/Ubuntu-16.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -__postgresql_version: "9.5" -__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" -__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" -__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-contrib - - libpq-dev diff --git a/roles/geerlingguy.postgresql/vars/Ubuntu-18.yml b/roles/geerlingguy.postgresql/vars/Ubuntu-18.yml deleted file mode 100644 index 201acc3..0000000 --- a/roles/geerlingguy.postgresql/vars/Ubuntu-18.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -__postgresql_version: "10" -__postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" -__postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" -__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" -__postgresql_daemon: postgresql -__postgresql_packages: - - postgresql - - postgresql-contrib - - libpq-dev diff --git a/roles/synapse/.editorconfig b/roles/synapse/.editorconfig deleted file mode 100644 index 5f98854..0000000 --- a/roles/synapse/.editorconfig +++ /dev/null @@ -1,7 +0,0 @@ -root = true -trim_trailing_whitespace = true - -[*.yml] -insert_final_newline = true -indent_style = space -indent_size = 2 diff --git a/roles/synapse/.gitignore b/roles/synapse/.gitignore deleted file mode 100644 index 508d994..0000000 --- a/roles/synapse/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tests/roles/ diff --git a/roles/synapse/.gitlab-ci.yml b/roles/synapse/.gitlab-ci.yml deleted file mode 100644 index 5d3ed4a..0000000 --- a/roles/synapse/.gitlab-ci.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# -*- coding: utf-8 -*- - -before_script: - - apt-get update -qy - - apt-get install -y python-dev python-pip - - git submodule update --init - - pip install --upgrade ansible ansible-lint - - ansible --version - - ansible-lint --version - -stages: - - ansible-lint - - ansible-syntax-check - -ansible-lint-pip: - stage: ansible-lint - script: - - ansible-lint tests/test-pip.yml - -ansible-lint-docker: - stage: ansible-lint - script: - - ansible-lint tests/test-docker.yml diff --git a/roles/synapse/README.md b/roles/synapse/README.md deleted file mode 100644 index a389e2e..0000000 --- a/roles/synapse/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# matrix-synapse - -Install a matrix synapse server. - -## Requirements - -The following should be present on the target system -* `pip` -* `systemd` -* `rsyslogd` -* `logrotate` - -## Role Variables - -### Mandatory Variables - -| Name | Type | Description | -| :--- | :--- | :--- | -| **matrix_server_name** | __string__ | | -| **matrix_synapse_tls_cert** | __string__ | server's TLS certificate chain (_when matrix_synapse_extra_config.no_tls is set to true_)| -| **matrix_synapse_tls_key** | __string__ | server's TLS key (_when matrix_synapse_extra_config.no_tls is set to true_)| -| **matrix_synapse_report_stats** | __bool__ | Report the stats to matrix.org | -| **matrix_synapse_pg_host** | __sting__ | postgresql server | -| **matrix_synapse_pg_user** | __string__ | postgresql user | -| **matrix_synapse_pg_pass** | __string__ | postgresql user's password | -| **matrix_synapse_pg_db** | __string__ | postgresql database | - -### Optional Variables - -| Name | Value | Description | -| :--- | :--- | :--- | -| matrix_synapse_base_path | "/opt/synapse" | -| matrix_synapse_secrets_path | "{{ matrix_synapse_base_path }}/secrets" -| matrix_synapse_extra_config | _None_ | configuration parameters as given in the [synapse configuration file](https://github.com/matrix-org/synapse/tree/master/docs) | -| matrix_synapse_dh_path | "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.dh" | -| matrix_synapse_baseurl | "https://{{ matrix_server_name }}" | -| matrix_synapse_signing_key_path | "{{ matrix_synapse_base_path }}/ssl/{{ matrix_server_name }}.signing.key" | -| matrix_synapse_version | "v1.0.0" | -| matrix_synapse_log_days_keep | 30 | -| matrix_synapse_deployment_method | pip | Either pip or docker [¹](#footnote_1) | -| matrix_synapse_supervision_method | systemd | Either systemd, runit or docker [¹](#footnote_1) | -| matrix_synapse_python_version | 3 | Default python version (2, 3) to be used | - -¹: Docker must be used for both or neither deployment and supervision - -## Dependencies - -__None__. - -## Example Playbook - -```yaml -#TODO: Add example -``` - -## License - -Apache 2.0 - -# Author Information - -* Michael Kaye -* Jan Christian Grünhage -* Emmanouil Kampitakis diff --git a/roles/synapse/TODO.md b/roles/synapse/TODO.md deleted file mode 100644 index b1ba7ce..0000000 --- a/roles/synapse/TODO.md +++ /dev/null @@ -1 +0,0 @@ -- Write a handler to restart the systemd service when upgrading diff --git a/roles/synapse/defaults/main.yml b/roles/synapse/defaults/main.yml deleted file mode 100644 index 5d41f76..0000000 --- a/roles/synapse/defaults/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -matrix_synapse_extra_config: {} -matrix_synapse_deployment_method: pip -matrix_synapse_supervision_method: systemd -matrix_synapse_base_path: "/opt/synapse" -matrix_synapse_secrets_path: "{{ matrix_synapse_base_path }}/secrets" -matrix_synapse_dh_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.dh" -matrix_synapse_baseurl: "https://{{ matrix_server_name }}" -matrix_synapse_signing_key_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.signing.key" -matrix_synapse_version: "v1.3.1" -matrix_synapse_log_dir: "/var/log/matrix_synapse" -matrix_synapse_log_days_keep: 30 -matrix_synapse_pid_file: "{{ matrix_synapse_base_path }}/synapse.pid" -matrix_synapse_docker_ports: ["8008:8008", "8448:8448"] -matrix_synapse_docker_labels: {} diff --git a/roles/synapse/files/log.config b/roles/synapse/files/log.config deleted file mode 100644 index c40da9b..0000000 --- a/roles/synapse/files/log.config +++ /dev/null @@ -1,29 +0,0 @@ -version: 1 - -formatters: - precise: - format: '%(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s' - -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - -handlers: - console: - class: logging.StreamHandler - formatter: precise - filters: [context] - -loggers: - synapse: - level: INFO - - synapse.storage.SQL: - # beware: increasing this to DEBUG will make synapse log sensitive - # information such as access tokens. - level: INFO - -root: - level: INFO - handlers: [console] diff --git a/roles/synapse/handlers/main.yml b/roles/synapse/handlers/main.yml deleted file mode 100644 index 937962a..0000000 --- a/roles/synapse/handlers/main.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: "reload systemd" - systemd: - daemon_reload: yes - -- name: "restart matrix-synapse using systemd" - service: - name: "matrix-synapse" - state: restarted - enabled: yes - when: matrix_synapse_supervision_method == "systemd" - listen: "restart matrix-synapse" - -- name: "restart synapse using docker" - docker_container: - name: synapse - state: started - restart: yes - when: matrix_synapse_supervision_method == "docker" - listen: "restart matrix-synapse" - -- name: restart rsyslog - become: yes - service: - name: rsyslog - state: restarted - when: matrix_synapse_supervision_method == "systemd" diff --git a/roles/synapse/library/matrix_signing_key.py b/roles/synapse/library/matrix_signing_key.py deleted file mode 100644 index 9aa6d08..0000000 --- a/roles/synapse/library/matrix_signing_key.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/python3 -# Copyright: (c) 2018, Emmanouil Kampitakis -# Apache 2.0 - -from ansible.module_utils.basic import AnsibleModule -from signedjson import key -import os - -def write_signing_key(path): - with open(path,'w') as f: - key.write_signing_keys( - f, - [key.generate_signing_key('first')] - ) - -def run_module(): - module_args = dict( - path=dict(type='str', required=True), - ) - - result = dict( - changed=False, - original_message='', - message='' - ) - - module = AnsibleModule( - argument_spec=module_args, - supports_check_mode=True - ) - - signing_key_path = module.params['path'] - - signing_key_exists = os.path.isfile(signing_key_path) - - if not signing_key_exists: - result['changed'] = True - if module.check_mode: - return result - - write_signing_key(signing_key_path) - - module.exit_json(**result) - -def main(): - run_module() - -if __name__ == '__main__': - main() - - diff --git a/roles/synapse/meta/.galaxy_install_info b/roles/synapse/meta/.galaxy_install_info deleted file mode 100644 index 735e9cf..0000000 --- a/roles/synapse/meta/.galaxy_install_info +++ /dev/null @@ -1,2 +0,0 @@ -install_date: Tue Sep 24 09:13:48 2019 -version: '' diff --git a/roles/synapse/meta/main.yml b/roles/synapse/meta/main.yml deleted file mode 100644 index a108ae7..0000000 --- a/roles/synapse/meta/main.yml +++ /dev/null @@ -1,16 +0,0 @@ -galaxy_info: - author: michaelkaye - description: Deploys a synapse server - - license: Apache 2.0 - - min_ansible_version: 2.0 - - platforms: - - name: Debian - versions: - - jessie - - galaxy_tags: [] - -dependencies: [] diff --git a/roles/synapse/synapse b/roles/synapse/synapse deleted file mode 120000 index 17c01eb..0000000 --- a/roles/synapse/synapse +++ /dev/null @@ -1 +0,0 @@ -synapse \ No newline at end of file diff --git a/roles/synapse/tasks/configure.yml b/roles/synapse/tasks/configure.yml deleted file mode 100644 index eda8b82..0000000 --- a/roles/synapse/tasks/configure.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -- name: create user - user: - name: synapse - state: present - register: synapse_user - tags: - - pre_install - -- name: create directory - file: - path: "{{ matrix_synapse_base_path }}" - state: directory - owner: synapse - group: synapse - tags: - - pre_install - -- name: Create secrets directory - file: - path: "{{ matrix_synapse_secrets_path }}" - state: directory - owner: synapse - group: synapse - tags: - - pre_install - -- name: Generate secrets - include_tasks: generate_secret.yml - loop: - - file: "macaroon.key" - var: "macaroon_file" - - file: "registration.key" - var: "registration_shared_secret_file" - - file: "form.key" - var: "form_secret_file" - loop_control: - loop_var: secret - -- name: Create directory for media storage - file: - path: "{{ item }}" - state: directory - owner: synapse - group: synapse - loop: - - "{{ matrix_synapse_config.media_store_path }}" - - "{{ matrix_synapse_config.uploads_path }}" - - "{{ matrix_synapse_base_path }}/tls" - -- name: Deploy config - copy: - content: "{{ matrix_synapse_config | to_nice_yaml }}" - dest: "{{ matrix_synapse_base_path }}/homeserver.yaml" - owner: synapse - group: synapse - notify: - - "restart matrix-synapse" - -- name: Configure logging - import_tasks: logging.yml - -- name: Create certificates - include_tasks: crypto.yml diff --git a/roles/synapse/tasks/crypto.yml b/roles/synapse/tasks/crypto.yml deleted file mode 100644 index 6e4b946..0000000 --- a/roles/synapse/tasks/crypto.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Install signedjson - pip: - name: signedjson - -- name: Create signing key - matrix_signing_key: - path: "{{ matrix_synapse_config.signing_key_path }}" - notify: - - "restart matrix-synapse" - -- name: Write server's certificate and private key - block: - - name: create DH parameters - openssl_dhparam: - path: "{{ matrix_synapse_dh_path }}" - owner: synapse - - name: Write certificate - copy: - content: "{{ matrix_synapse_tls_cert }}" - dest: "{{ matrix_synapse_config.tls_certificate_path }}" - owner: synapse - group: synapse - mode: "0644" - - name: Write keyfile - copy: - content: "{{ matrix_synapse_tls_key }}" - dest: "{{ matrix_synapse_config.tls_private_key_path }}" - owner: synapse - group: synapse - mode: "0600" - when: not matrix_synapse_config.no_tls diff --git a/roles/synapse/tasks/deployment.yml b/roles/synapse/tasks/deployment.yml deleted file mode 100644 index a58f217..0000000 --- a/roles/synapse/tasks/deployment.yml +++ /dev/null @@ -1,78 +0,0 @@ ---- -- name: install synapse with pip into virtualenv - block: - - name: Install dependencies - apt: - name: - - git - - build-essential - - python3-dev - - python-virtualenv - - python-pip - - python-setuptools - - sqlite3 - - libffi-dev - - libssl-dev - - libjpeg-dev - - libxslt1-dev - - libpq-dev - state: present - cache_valid_time: 1800 - tags: - - pre_install - - - name: Create virtualenv - pip: - name: - - pip - - setuptools - virtualenv: "{{ matrix_synapse_base_path }}/env" - virtualenv_python: python3 - extra_args: --upgrade - tags: - - pre_install - - - name: Clone synapse - git: - repo: https://github.com/matrix-org/synapse - dest: "{{ matrix_synapse_base_path }}/synapse" - accept_hostkey: yes - version: "{{ matrix_synapse_version }}" - register: clone_synapse - tags: - - pre_install - - - name: Install Synapse - pip: - name: "{{ matrix_synapse_base_path }}/synapse[matrix-synapse-ldap3,postgres,resources.consent,acme,url_preview]" - virtualenv: "{{ matrix_synapse_base_path }}/env" - when: clone_synapse.changed - tags: - - skip_ansible_lint # skip when clause - - pre_install - notify: restart matrix-synapse - when: matrix_synapse_deployment_method == "pip" - -- name: install synapse with docker - docker_container: - name: synapse - image: "docker.io/matrixdotorg/synapse:{{ matrix_synapse_version }}" - ports: "{{ matrix_synapse_docker_ports }}" - labels: "{{ matrix_synapse_docker_labels }}" - restart_policy: unless-stopped - recreate: true - pull: true - entrypoint: "python" - command: - - "-m" - - "synapse.app.homeserver" - - "-c" - - "{{ matrix_synapse_base_path }}/homeserver.yaml" - user: "{{ synapse_user.uid }}:{{ synapse_user.group }}" - volumes: - - "{{ matrix_synapse_config.media_store_path }}:{{ matrix_synapse_config.media_store_path }}" - - "{{ matrix_synapse_config.uploads_path }}:{{ matrix_synapse_config.uploads_path }}" - - "{{ matrix_synapse_base_path }}/homeserver.yaml:{{ matrix_synapse_base_path }}/homeserver.yaml" - - "{{ matrix_synapse_base_path }}/log.config:{{ matrix_synapse_base_path }}/log.config" - - "{{ matrix_synapse_base_path }}/tls:{{ matrix_synapse_base_path }}/tls" - when: matrix_synapse_deployment_method == "docker" diff --git a/roles/synapse/tasks/generate_secret.yml b/roles/synapse/tasks/generate_secret.yml deleted file mode 100644 index 8818a28..0000000 --- a/roles/synapse/tasks/generate_secret.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Set full file path - set_fact: - secret_file_path: "{{ matrix_synapse_secrets_path }}/{{ secret.file }}" - -- name: Check if secret exists - stat: - path: "{{ secret_file_path }}" - register: secret_file_stat - -- name: Generate random string - copy: - content: "{{ lookup('password', '/dev/null chars=ascii_letters,digits length=42') }}" - dest: "{{ secret_file_path }}" - owner: synapse - group: synapse - mode: "0600" - when: - - not secret_file_stat.stat.exists -# TODO: This below is a dirty hack and should be properly revisited -- name: Retrieve secret - slurp: - src: "{{ secret_file_path }}" - register: secret_var - -- name: Set secret.var fact - set_fact: { "{{ secret.var }}": "{{ secret_var }}" } diff --git a/roles/synapse/tasks/logging.yml b/roles/synapse/tasks/logging.yml deleted file mode 100644 index 7406f3a..0000000 --- a/roles/synapse/tasks/logging.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- name: Logging config (systemd) - block: - - name: create logging folder - file: - name: "{{ matrix_synapse_log_dir }}" - state: directory - owner: synapse - group: synapse - - - name: copy syslog config - template: - src: syslog-synapse.conf.j2 - dest: /etc/rsyslog.d/matrix_synapse.conf - owner: root - notify: restart rsyslog - - - name: template logrotate config - template: - src: logrotate.j2 - dest: /etc/logrotate.d/matrix_synapse - owner: root - when: matrix_synapse_supervision_method == "systemd" - # TODO: Figure out how to make sure that logging ends up in rsyslog no matter what system we run on - -- name: Deploy log config - copy: - src: "log.config" - dest: "{{ matrix_synapse_base_path }}/log.config" - owner: synapse - group: synapse - notify: - - "restart matrix-synapse" - - diff --git a/roles/synapse/tasks/main.yml b/roles/synapse/tasks/main.yml deleted file mode 100644 index 6608935..0000000 --- a/roles/synapse/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: check that sypervision and deployment are compatible - fail: - msg: "Either both or neither of deployment and supervision method should be docker." - when: (matrix_synapse_supervision_method == "docker" and matrix_synapse_deployment_method != "docker") or - (matrix_synapse_deployment_method == "docker" and matrix_synapse_supervision_method != "docker") - -- name: configure synapse - import_tasks: configure.yml - -- name: deploy synapse - import_tasks: deployment.yml - -- name: configure service - import_tasks: systemd.yml - when: matrix_synapse_supervision_method == "systemd" diff --git a/roles/synapse/tasks/systemd.yml b/roles/synapse/tasks/systemd.yml deleted file mode 100644 index 7e4295b..0000000 --- a/roles/synapse/tasks/systemd.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Deploy service file - template: - src: "matrix-synapse.service.j2" - dest: "/etc/systemd/system/matrix-synapse.service" - mode: 0755 - notify: - - "reload systemd" - - "restart matrix-synapse" diff --git a/roles/synapse/templates/logrotate.j2 b/roles/synapse/templates/logrotate.j2 deleted file mode 100644 index c917561..0000000 --- a/roles/synapse/templates/logrotate.j2 +++ /dev/null @@ -1,10 +0,0 @@ -{{ ansible_managed | comment }} -/var/log/matrix_synapse/matrix_synapse.log { - daily - rotate {{ matrix_synapse_log_days_keep }} - compress - shred - postrotate - /usr/bin/pkill -HUP rsyslogd - endscript -} diff --git a/roles/synapse/templates/matrix-synapse.service.j2 b/roles/synapse/templates/matrix-synapse.service.j2 deleted file mode 100644 index 2e0adca..0000000 --- a/roles/synapse/templates/matrix-synapse.service.j2 +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description="Matrix Synapse Server (synapse)" - -[Service] -Type=simple -WorkingDirectory={{ matrix_synapse_base_path }} -ExecStart={{ matrix_synapse_base_path }}/env/bin/python -m synapse.app.homeserver --config-path={{ matrix_synapse_base_path }}/homeserver.yaml -ExecStop={{ matrix_synapse_base_path }}/env/bin/synctl stop {{ matrix_synapse_base_path }}/homeserver.yaml -User=synapse -Group=synapse -Restart=always -StandardOutput=syslog -SyslogIdentifier=matrix_synapse - -[Install] -WantedBy=default.target diff --git a/roles/synapse/templates/syslog-synapse.conf.j2 b/roles/synapse/templates/syslog-synapse.conf.j2 deleted file mode 100644 index d98c550..0000000 --- a/roles/synapse/templates/syslog-synapse.conf.j2 +++ /dev/null @@ -1,2 +0,0 @@ -if $programname == 'matrix_synapse' then {{ matrix_synapse_log_dir }}/matrix_synapse.log -if $programname == 'matrix_synapse' then ~ diff --git a/roles/synapse/tests/.gitignore b/roles/synapse/tests/.gitignore deleted file mode 100644 index a058c8c..0000000 --- a/roles/synapse/tests/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.vagrant -*.retry diff --git a/roles/synapse/tests/Vagrantfile b/roles/synapse/tests/Vagrantfile deleted file mode 100644 index 132c5bd..0000000 --- a/roles/synapse/tests/Vagrantfile +++ /dev/null @@ -1,25 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - config.vm.define "pip" do |pip| - pip.vm.box = "debian/stretch64" - - pip.vm.network "forwarded_port", guest: 8008, host: 8008 - pip.vm.network "forwarded_port", guest: 8448, host: 8448 - - pip.vm.provision "ansible" do |ansible| - ansible.playbook = "test-pip.yml" - end - end - config.vm.define "docker" do |docker| - docker.vm.box = "debian/stretch64" - - docker.vm.network "forwarded_port", guest: 8008, host: 8009 - docker.vm.network "forwarded_port", guest: 8448, host: 8449 - - docker.vm.provision "ansible" do |ansible| - ansible.playbook = "test-docker.yml" - end - end -end diff --git a/roles/synapse/tests/ansible.cfg b/roles/synapse/tests/ansible.cfg deleted file mode 100644 index 711a199..0000000 --- a/roles/synapse/tests/ansible.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[defaults] -nocows=1 -roles_path=./roles:./../../ diff --git a/roles/synapse/tests/requirements.yml b/roles/synapse/tests/requirements.yml deleted file mode 100644 index 75f1808..0000000 --- a/roles/synapse/tests/requirements.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- role: geerlingguy.pip -- role: geerlingguy.docker -- role: geerlingguy.postgresql diff --git a/roles/synapse/tests/test-docker.yml b/roles/synapse/tests/test-docker.yml deleted file mode 100644 index 5352b68..0000000 --- a/roles/synapse/tests/test-docker.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- hosts: all - become: true - tasks: - - name: Flush handlers - meta: flush_handlers - - - name: Check if the api returns the correct version - uri: - url: "http://localhost:8008/_matrix/federation/v1/version" - return_content: true - register: api_version - until: api_version.status == 200 - retries: 10 - delay: 2 - - - name: Check returned api version - fail: > - Return value is not as expected {{ api_version }} - when: matrix_synapse_version != "v"~(api_version.content | from_json).server.version - vars: - dbname: synapse - dbuser: synapse_user - dbpw: synapse_password - matrix_synapse_deployment_method: docker - matrix_synapse_supervision_method: docker - roles: - - role: geerlingguy.pip - pip_install_packages: - - name: docker - - role: geerlingguy.docker - - role: geerlingguy.postgresql - postgresql_databases: - - name: "{{ dbname }}" - postgresql_users: - - name: "{{ dbuser }}" - password: "{{ dbpw }}" - postgresql_global_config_options: - - option: listen_addresses - value: "172.17.0.1" - postgresql_hba_entries: - - { type: local, database: all, user: all, auth_method: trust } - - { type: host, database: "{{ dbname }}", user: "{{ dbuser }}", address: "172.17.0.1/16", auth_method: md5 } - - role: matrix-ansible-synapse - matrix_server_name: localhost - matrix_synapse_report_stats: false - matrix_synapse_pg_host: 172.17.0.1 - matrix_synapse_pg_user: "{{ dbuser }}" - matrix_synapse_pg_pass: "{{ dbpw }}" - matrix_synapse_pg_db: "{{ dbname }}" - matrix_synapse_extra_config: - no_tls: true diff --git a/roles/synapse/tests/test-pip.yml b/roles/synapse/tests/test-pip.yml deleted file mode 100644 index 156e607..0000000 --- a/roles/synapse/tests/test-pip.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- hosts: all - become: true - vars: - dbname: synapse - dbuser: synapse_user - dbpw: synapse_password - tasks: - - name: Flush handlers - meta: flush_handlers - - - name: Check if the api returns the correct version - uri: - url: "http://localhost:8008/_matrix/federation/v1/version" - return_content: true - register: api_version - until: api_version.status == 200 - retries: 10 - delay: 2 - - - name: Check returned api version - fail: - msg: "Return value {{ api_version }} is not as expected {{ matrix_synapse_version }}" - when: matrix_synapse_version != "v"~(api_version.content | from_json).server.version - roles: - - role: geerlingguy.pip - - role: geerlingguy.postgresql - postgresql_databases: - - name: "{{ dbname }}" - postgresql_users: - - name: "{{ dbuser }}" - password: "{{ dbpw }}" - postgresql_global_config_options: - - option: listen_addresses - value: "*" - - role: matrix-ansible-synapse - matrix_server_name: localhost - matrix_synapse_report_stats: false - matrix_synapse_pg_host: localhost - matrix_synapse_pg_user: "{{ dbuser }}" - matrix_synapse_pg_pass: "{{ dbpw }}" - matrix_synapse_pg_db: "{{ dbname }}" - matrix_synapse_extra_config: - no_tls: true diff --git a/roles/synapse/vars/main.yml b/roles/synapse/vars/main.yml deleted file mode 100644 index f149c58..0000000 --- a/roles/synapse/vars/main.yml +++ /dev/null @@ -1,141 +0,0 @@ ---- -matrix_synapse_config: "{{ matrix_synapse_base_config | combine(matrix_synapse_extra_config, recursive=True) }}" -matrix_synapse_base_config: - server_name: "{{ matrix_server_name }}" - tls_certificate_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.crt" - tls_private_key_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.key" - acme: - enabled: false - url: https://acme-v01.api.letsencrypt.org/directory - port: 80 - bind_addresses: ['::', '0.0.0.0'] - reprovision_threshold: 30 - no_tls: false - tls_fingerprints: [] - pid_file: "{{ matrix_synapse_base_path }}/synapse.pid" - soft_file_limit: 0 - use_presence: true - listeners: - - port: 8448 - bind_addresses: - - '::' - - '0.0.0.0' - type: http - tls: true - x_forwarded: false - resources: - - names: [client] - compress: true - - names: [federation] - compress: false - - port: 8008 - tls: false - bind_addresses: - - '::' - - '0.0.0.0' - type: http - x_forwarded: false - resources: - - names: [client] - compress: true - - names: [federation] - compress: false - database: - name: "psycopg2" - args: - user: "{{ matrix_synapse_pg_user }}" - password: "{{ matrix_synapse_pg_pass }}" - database: "{{ matrix_synapse_pg_db }}" - host: "{{ matrix_synapse_pg_host }}" - cp_min: 5 - cp_max: 10 - log_config: "{{ matrix_synapse_base_path }}/log.config" - event_cache_size: "10K" - rc_messages_per_second: 0.2 - rc_message_burst_count: 10.0 - federation_rc_window_size: 1000 - federation_rc_sleep_limit: 10 - federation_rc_sleep_delay: 500 - federation_rc_reject_limit: 50 - federation_rc_concurrent: 3 - media_store_path: "{{ matrix_synapse_base_path }}/media_store" - uploads_path: "{{ matrix_synapse_base_path }}/uploads" - max_upload_size: "23M" - max_image_pixels: "32M" - dynamic_thumbnails: false - 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 - url_preview_enabled: true - 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' - - '100.64.0.0/10' - - '169.254.0.0/16' - - '::1/128' - - 'fe80::/64' - - 'fc00::/7' - url_preview_url_blacklist: - - username: '*' - - netloc: 'google.com' - - netloc: '*.google.com' - - netloc: 'twitter.com' - - netloc: '*.twitter.com' - - netloc: 't.co' - - netloc: '*.t.co' - max_spider_size: "10M" - enable_registration: False - registration_shared_secret: > - "{{ registration_shared_secret_file.content | b64decode }}" - form_secret: "{{ form_secret_file.content | b64decode }}" - bcrypt_rounds: 12 - allow_guest_access: False - trusted_third_party_id_servers: - - matrix.org - - vector.im - autocreate_auto_join_rooms: true - enable_metrics: False - report_stats: "{{ matrix_synapse_report_stats }}" - room_invite_state_types: - - "m.room.join_rules" - - "m.room.canonical_alias" - - "m.room.avatar" - - "m.room.name" - app_service_config_files: [] - track_appservice_user_ips: False - macaroon_secret_key: "{{ macaroon_file.content | b64decode }}" - expire_access_token: False - signing_key_path: "{{ matrix_synapse_signing_key_path }}" - old_signing_keys: {} - key_refresh_interval: "1d" # 1 Day. - # TODO: More servers should be added - perspectives: - servers: - "matrix.org": - verify_keys: - "ed25519:auto": - key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw" - password_config: - enabled: true - push: - include_content: false - enable_group_creation: true - alias_creation_rules: - - user_id: "*" - alias: "*" - action: allow diff --git a/synapse.yml b/synapse.yml deleted file mode 100644 index ab59024..0000000 --- a/synapse.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- hosts: synapse -# todo: create user for synapse - vars: - # matrix_synapse_version: "v1.3.1" - # localhosts causes certificate generation bugs - # matrix_server_name: localhost - matrix_server_name: dev - matrix_synapse_deployment_method: pip - matrix_synapse_baseurl: "https://{{ matrix_server_name }}" - # matrix_synapse_signing_key_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.signing.key" - - - - matrix_synapse_pg_host: localhost - matrix_synapse_pg_user: "{{ synapse_dbuser }}" - matrix_synapse_pg_pass: "{{ synapse_dbpw }}" - matrix_synapse_pg_db: "{{ synapse_dbname }}" - matrix_synapse_report_stats: false # Report stats to matrix.org? - - matrix_synapse_extra_config: # no_tls:true disables port 8448 - # no_tls: false - no_tls: true # Because DH bug - # If false: - # tls_certificate_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.crt" - # tls_private_key_path: "{{ matrix_synapse_base_path }}/tls/{{ matrix_server_name }}.key" - # acme: - # enabled: false - # url: https://acme-v01.api.letsencrypt.org/directory - # port: 80 - # bind_addresses: ['::', '0.0.0.0'] - # reprovision_threshold: 30 - # matrix_synapse_tls_cert: "" - # matrix_synapse_tls_key: "" - - # pre_tasks: - # tasks: - roles: - - synapse \ No newline at end of file diff --git a/templates/docker-compose-matrix.yml.j2 b/templates/docker-compose-matrix.yml.j2 new file mode 100644 index 0000000..4322016 --- /dev/null +++ b/templates/docker-compose-matrix.yml.j2 @@ -0,0 +1,70 @@ +# This compose file is compatible with Compose itself, it might need some +# adjustments to run properly with stack. + +version: '3' + +services: + {# matrix_synapse_version: "v1.5.1-py3" + # matrix_synapse_version: "v1.5.1" + matrix_server_name: matrix-sonic-beta.local + + + matrix_synapse_pg_host: synapse-postgres + matrix_synapse_pg_user: "" + matrix_synapse_pg_pass: "" + matrix_synapse_pg_db: " #} + synapse: + {# build: + context: ../.. + dockerfile: docker/Dockerfile #} + image: "docker.io/matrixdotorg/synapse: {{ matrix_synapse_version }}" + # Since synapse does not retry to connect to the database, restart upon + # failure + restart: unless-stopped + # See the readme for a full documentation of the environment settings + environment: + - SYNAPSE_CONFIG_PATH=/etc/homeserver.yaml + volumes: + # You may either store all the files in a local folder + - ./matrix-config:/etc + - ./files:/data + # .. or you may split this between different storage points + # - ./files:/data + # - /path/to/ssd:/data/uploads + # - /path/to/large_hdd:/data/media + depends_on: + - db + # In order to expose Synapse, remove one of the following, you might for + # instance expose the TLS port directly: + ports: + - 8008:8008/tcp + labels: + {# # The following lines are valid for Traefik version 1.x: + - traefik.enable=true + - traefik.frontend.rule=Host:my.matrix.Host + - traefik.port=8008 + # Alternatively, for Traefik version 2.0: + - traefik.enable=true + - traefik.http.routers.http-synapse.entryPoints=http + - traefik.http.routers.http-synapse.rule=Host(`my.matrix.host`) + - traefik.http.middlewares.https_redirect.redirectscheme.scheme=https + - traefik.http.middlewares.https_redirect.redirectscheme.permanent=true + - traefik.http.routers.http-synapse.middlewares=https_redirect + - traefik.http.routers.https-synapse.entryPoints=https + - traefik.http.routers.https-synapse.rule=Host(`my.matrix.host`) + - traefik.http.routers.https-synapse.service=synapse + - traefik.http.routers.https-synapse.tls=true + - traefik.http.services.synapse.loadbalancer.server.port=8008 + - traefik.http.routers.https-synapse.tls.certResolver=le-ssl #} + + db: + image: docker.io/postgres:10-alpine + # Change that password, of course! + environment: + - POSTGRES_USER=synapse + - POSTGRES_PASSWORD=changeme + volumes: + # You may store the database tables in a local folder.. + - ./schemas:/var/lib/postgresql/data + # .. or store them on some high performance storage for better results + # - /path/to/ssd/storage:/var/lib/postgresql/data diff --git a/templates/homeserver.yaml.example b/templates/homeserver.yaml.example new file mode 100644 index 0000000..ee00186 --- /dev/null +++ b/templates/homeserver.yaml.example @@ -0,0 +1,1598 @@ +# vim:ft=yaml + +## Server ## + +# The domain name of the server, with optional explicit port. +# This is used by remote servers to connect to this server, +# e.g. matrix.org, localhost:8080, etc. +# This is also the last part of your UserID. +# +server_name: "myserver.invalid" + +# When running as a daemon, the file to store the pid in +# +pid_file: /data/homeserver.pid + +# The path to the web client which will be served at /_matrix/client/ +# if 'webclient' is configured under the 'listeners' configuration. +# +#web_client_location: "/path/to/web/root" + +# The public-facing base URL that clients use to access this HS +# (not including _matrix/...). This is the same URL a user would +# enter into the 'custom HS URL' field on their client. If you +# use synapse with a reverse proxy, this should be the URL to reach +# synapse via the proxy. +# +#public_baseurl: https://example.com/ + +# 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 + +# Set to false to disable presence tracking on this homeserver. +# +#use_presence: false + +# Whether to require authentication to retrieve profile data (avatars, +# display names) of other users through the client API. Defaults to +# 'false'. Note that profile data is also available via the federation +# API, so this setting is of limited value if federation is enabled on +# the server. +# +#require_auth_for_profile_requests: true + +# If set to 'false', requires authentication to access the server's public rooms +# directory through the client API. Defaults to 'true'. +# +#allow_public_rooms_without_auth: false + +# If set to 'false', forbids any other homeserver to fetch the server's public +# rooms directory via federation. Defaults to 'true'. +# +#allow_public_rooms_over_federation: false + +# The default room version for newly created rooms. +# +# Known room versions are listed here: +# https://matrix.org/docs/spec/#complete-list-of-room-versions +# +# For example, for room version 1, default_room_version should be set +# to "1". +# +#default_room_version: "4" + +# The GC threshold parameters to pass to `gc.set_threshold`, if defined +# +#gc_thresholds: [700, 10, 10] + +# Set the limit on the returned events in the timeline in the get +# and sync operations. The default value is -1, means no upper limit. +# +#filter_timeline_limit: 5000 + +# Whether room invites to users on this server should be blocked +# (except those sent by local server admins). The default is False. +# +#block_non_admin_invites: True + +# Room searching +# +# If disabled, new messages will not be indexed for searching and users +# will receive errors when searching for messages. Defaults to enabled. +# +#enable_search: false + +# Restrict federation to the following whitelist of domains. +# N.B. we recommend also firewalling your federation listener to limit +# inbound federation traffic as early as possible, rather than relying +# purely on this application-layer restriction. If not specified, the +# default is to whitelist everything. +# +#federation_domain_whitelist: +# - lon.example.com +# - nyc.example.com +# - syd.example.com + +# Prevent federation requests from being sent to the following +# blacklist IP address CIDR ranges. If this option is not specified, or +# specified with an empty list, no ip range blacklist will be enforced. +# +# As of Synapse v1.4.0 this option also affects any outbound requests to identity +# servers provided by user input. +# +# (0.0.0.0 and :: are always blacklisted, whether or not they are explicitly +# listed here, since they correspond to unroutable addresses.) +# +federation_ip_range_blacklist: + - '127.0.0.0/8' + - '10.0.0.0/8' + - '172.16.0.0/12' + - '192.168.0.0/16' + - '100.64.0.0/10' + - '169.254.0.0/16' + - '::1/128' + - 'fe80::/64' + - 'fc00::/7' + +# List of ports that Synapse should listen on, their purpose and their +# configuration. +# +# Options for each listener include: +# +# port: the TCP port to bind to +# +# bind_addresses: a list of local addresses to listen on. The default is +# 'all local interfaces'. +# +# type: the type of listener. Normally 'http', but other valid options are: +# 'manhole' (see docs/manhole.md), +# 'metrics' (see docs/metrics-howto.md), +# 'replication' (see docs/workers.md). +# +# tls: set to true to enable TLS for this listener. Will use the TLS +# key/cert specified in tls_private_key_path / tls_certificate_path. +# +# x_forwarded: Only valid for an 'http' listener. Set to true to use the +# X-Forwarded-For header as the client IP. Useful when Synapse is +# behind a reverse-proxy. +# +# resources: Only valid for an 'http' listener. A list of resources to host +# on this port. Options for each resource are: +# +# names: a list of names of HTTP resources. See below for a list of +# valid resource names. +# +# compress: set to true to enable HTTP comression for this resource. +# +# additional_resources: Only valid for an 'http' listener. A map of +# additional endpoints which should be loaded via dynamic modules. +# +# Valid resource names are: +# +# client: the client-server API (/_matrix/client), and the synapse admin +# API (/_synapse/admin). Also implies 'media' and 'static'. +# +# consent: user consent forms (/_matrix/consent). See +# docs/consent_tracking.md. +# +# federation: the server-server API (/_matrix/federation). Also implies +# 'media', 'keys', 'openid' +# +# keys: the key discovery API (/_matrix/keys). +# +# media: the media API (/_matrix/media). +# +# metrics: the metrics interface. See docs/metrics-howto.md. +# +# openid: OpenID authentication. +# +# replication: the HTTP replication API (/_synapse/replication). See +# docs/workers.md. +# +# static: static resources under synapse/static (/_matrix/static). (Mostly +# useful for 'fallback authentication'.) +# +# webclient: A web client. Requires web_client_location to be set. +# +listeners: + # TLS-enabled listener: for when matrix traffic is sent directly to synapse. + # + # Disabled by default. To enable it, uncomment the following. (Note that you + # will also need to give Synapse a TLS key and certificate: see the TLS section + # below.) + # + #- port: 8448 + # type: http + # tls: true + # resources: + # - names: [client, federation] + + # Unsecure HTTP listener: for when matrix traffic passes through a reverse proxy + # that unwraps TLS. + # + # If you plan to use a reverse proxy, please see + # https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md. + # + - port: 8008 + tls: false + type: http + x_forwarded: true + + resources: + - names: [client, federation] + compress: false + + # example additional_resources: + # + #additional_resources: + # "/_matrix/my/custom/endpoint": + # module: my_module.CustomRequestHandler + # config: {} + + # Turn on the twisted ssh manhole service on localhost on the given + # port. + # + #- port: 9000 + # bind_addresses: ['::1', '127.0.0.1'] + # type: manhole + + +## Homeserver blocking ## + +# How to reach the server admin, used in ResourceLimitError +# +#admin_contact: 'mailto:admin@server.com' + +# Global blocking +# +#hs_disabled: False +#hs_disabled_message: 'Human readable reason for why the HS is blocked' +#hs_disabled_limit_type: 'error code(str), to help clients decode reason' + +# Monthly Active User Blocking +# +# Used in cases where the admin or server owner wants to limit to the +# number of monthly active users. +# +# 'limit_usage_by_mau' disables/enables monthly active user blocking. When +# anabled and a limit is reached the server returns a 'ResourceLimitError' +# with error type Codes.RESOURCE_LIMIT_EXCEEDED +# +# 'max_mau_value' is the hard limit of monthly active users above which +# the server will start blocking user actions. +# +# 'mau_trial_days' is a means to add a grace period for active users. It +# means that users must be active for this number of days before they +# can be considered active and guards against the case where lots of users +# sign up in a short space of time never to return after their initial +# session. +# +#limit_usage_by_mau: False +#max_mau_value: 50 +#mau_trial_days: 2 + +# If enabled, the metrics for the number of monthly active users will +# be populated, however no one will be limited. If limit_usage_by_mau +# is true, this is implied to be true. +# +#mau_stats_only: False + +# Sometimes the server admin will want to ensure certain accounts are +# never blocked by mau checking. These accounts are specified here. +# +#mau_limit_reserved_threepids: +# - medium: 'email' +# address: 'reserved_user@example.com' + +# Used by phonehome stats to group together related servers. +#server_context: context + +# Resource-constrained Homeserver Settings +# +# If limit_remote_rooms.enabled is True, the room complexity will be +# checked before a user joins a new remote room. If it is above +# limit_remote_rooms.complexity, it will disallow joining or +# instantly leave. +# +# limit_remote_rooms.complexity_error can be set to customise the text +# displayed to the user when a room above the complexity threshold has +# its join cancelled. +# +# Uncomment the below lines to enable: +#limit_remote_rooms: +# enabled: True +# complexity: 1.0 +# complexity_error: "This room is too complex." + +# Whether to require a user to be in the room to add an alias to it. +# Defaults to 'true'. +# +#require_membership_for_aliases: false + +# Whether to allow per-room membership profiles through the send of membership +# events with profile information that differ from the target's global profile. +# Defaults to 'true'. +# +#allow_per_room_profiles: false + +# How long to keep redacted events in unredacted form in the database. After +# this period redacted events get replaced with their redacted form in the DB. +# +# Defaults to `7d`. Set to `null` to disable. +# +#redaction_retention_period: 28d + +# How long to track users' last seen time and IPs in the database. +# +# Defaults to `28d`. Set to `null` to disable clearing out of old rows. +# +#user_ips_max_age: 14d + + +## TLS ## + +# PEM-encoded X509 certificate for TLS. +# This certificate, as of Synapse 1.0, will need to be a valid and verifiable +# certificate, signed by a recognised Certificate Authority. +# +# See 'ACME support' below to enable auto-provisioning this certificate via +# Let's Encrypt. +# +# If supplying your own, be sure to use a `.pem` file that includes the +# full certificate chain including any intermediate certificates (for +# instance, if using certbot, use `fullchain.pem` as your certificate, +# not `cert.pem`). +# +#tls_certificate_path: "/data/myserver.invalid.tls.crt" + +# PEM-encoded private key for TLS +# +#tls_private_key_path: "/data/myserver.invalid.tls.key" + +# Whether to verify TLS server certificates for outbound federation requests. +# +# Defaults to `true`. To disable certificate verification, uncomment the +# following line. +# +#federation_verify_certificates: false + +# The minimum TLS version that will be used for outbound federation requests. +# +# Defaults to `1`. Configurable to `1`, `1.1`, `1.2`, or `1.3`. Note +# that setting this value higher than `1.2` will prevent federation to most +# of the public Matrix network: only configure it to `1.3` if you have an +# entirely private federation setup and you can ensure TLS 1.3 support. +# +#federation_client_minimum_tls_version: 1.2 + +# Skip federation certificate verification on the following whitelist +# of domains. +# +# This setting should only be used in very specific cases, such as +# federation over Tor hidden services and similar. For private networks +# of homeservers, you likely want to use a private CA instead. +# +# Only effective if federation_verify_certicates is `true`. +# +#federation_certificate_verification_whitelist: +# - lon.example.com +# - *.domain.com +# - *.onion + +# List of custom certificate authorities for federation traffic. +# +# This setting should only normally be used within a private network of +# homeservers. +# +# Note that this list will replace those that are provided by your +# operating environment. Certificates must be in PEM format. +# +#federation_custom_ca_list: +# - myCA1.pem +# - myCA2.pem +# - myCA3.pem + +# ACME support: This will configure Synapse to request a valid TLS certificate +# for your configured `server_name` via Let's Encrypt. +# +# Note that provisioning a certificate in this way requires port 80 to be +# routed to Synapse so that it can complete the http-01 ACME challenge. +# By default, if you enable ACME support, Synapse will attempt to listen on +# port 80 for incoming http-01 challenges - however, this will likely fail +# with 'Permission denied' or a similar error. +# +# There are a couple of potential solutions to this: +# +# * If you already have an Apache, Nginx, or similar listening on port 80, +# you can configure Synapse to use an alternate port, and have your web +# server forward the requests. For example, assuming you set 'port: 8009' +# below, on Apache, you would write: +# +# ProxyPass /.well-known/acme-challenge http://localhost:8009/.well-known/acme-challenge +# +# * Alternatively, you can use something like `authbind` to give Synapse +# permission to listen on port 80. +# +acme: + # ACME support is disabled by default. Set this to `true` and uncomment + # tls_certificate_path and tls_private_key_path above to enable it. + # + enabled: False + + # Endpoint to use to request certificates. If you only want to test, + # use Let's Encrypt's staging url: + # https://acme-staging.api.letsencrypt.org/directory + # + #url: https://acme-v01.api.letsencrypt.org/directory + + # Port number to listen on for the HTTP-01 challenge. Change this if + # you are forwarding connections through Apache/Nginx/etc. + # + port: 80 + + # Local addresses to listen on for incoming connections. + # Again, you may want to change this if you are forwarding connections + # through Apache/Nginx/etc. + # + bind_addresses: ['::', '0.0.0.0'] + + # How many days remaining on a certificate before it is renewed. + # + reprovision_threshold: 30 + + # The domain that the certificate should be for. Normally this + # should be the same as your Matrix domain (i.e., 'server_name'), but, + # by putting a file at 'https:///.well-known/matrix/server', + # you can delegate incoming traffic to another server. If you do that, + # you should give the target of the delegation here. + # + # For example: if your 'server_name' is 'example.com', but + # 'https://example.com/.well-known/matrix/server' delegates to + # 'matrix.example.com', you should put 'matrix.example.com' here. + # + # If not set, defaults to your 'server_name'. + # + domain: matrix.example.com + + # file to use for the account key. This will be generated if it doesn't + # exist. + # + # If unspecified, we will use CONFDIR/client.key. + # + account_key_file: /data/acme_account.key + +# List of allowed TLS fingerprints for this server to publish along +# with the signing keys for this server. Other matrix servers that +# make HTTPS requests to this server will check that the TLS +# certificates returned by this server match one of the fingerprints. +# +# Synapse automatically adds the fingerprint of its own certificate +# to the list. So if federation traffic is handled directly by synapse +# then no modification to the list is required. +# +# If synapse is run behind a load balancer that handles the TLS then it +# will be necessary to add the fingerprints of the certificates used by +# the loadbalancers to this list if they are different to the one +# synapse is using. +# +# Homeservers are permitted to cache the list of TLS fingerprints +# returned in the key responses up to the "valid_until_ts" returned in +# key. It may be necessary to publish the fingerprints of a new +# certificate and wait until the "valid_until_ts" of the previous key +# responses have passed before deploying it. +# +# You can calculate a fingerprint from a given TLS listener via: +# openssl s_client -connect $host:$port < /dev/null 2> /dev/null | +# openssl x509 -outform DER | openssl sha256 -binary | base64 | tr -d '=' +# or by checking matrix.org/federationtester/api/report?server_name=$host +# +#tls_fingerprints: [{"sha256": ""}] + + + +## Database ## + +database: + # The database engine name + name: "sqlite3" + # Arguments to pass to the engine + args: + # Path to the database + database: "/data/homeserver.db" + +# Number of events to cache in memory. +# +#event_cache_size: 10K + + +## Logging ## + +# A yaml python logging config file as described by +# https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# +log_config: "/data/myserver.invalid.log.config" + + +## Ratelimiting ## + +# Ratelimiting settings for client actions (registration, login, messaging). +# +# Each ratelimiting configuration is made of two parameters: +# - per_second: number of requests a client can send per second. +# - burst_count: number of requests a client can send before being throttled. +# +# Synapse currently uses the following configurations: +# - one for messages that ratelimits sending based on the account the client +# is using +# - one for registration that ratelimits registration requests based on the +# client's IP address. +# - one for login that ratelimits login requests based on the client's IP +# address. +# - one for login that ratelimits login requests based on the account the +# client is attempting to log into. +# - one for login that ratelimits login requests based on the account the +# client is attempting to log into, based on the amount of failed login +# attempts for this account. +# - one for ratelimiting redactions by room admins. If this is not explicitly +# set then it uses the same ratelimiting as per rc_message. This is useful +# to allow room admins to deal with abuse quickly. +# +# The defaults are as shown below. +# +#rc_message: +# per_second: 0.2 +# burst_count: 10 +# +#rc_registration: +# per_second: 0.17 +# burst_count: 3 +# +#rc_login: +# address: +# per_second: 0.17 +# burst_count: 3 +# account: +# per_second: 0.17 +# burst_count: 3 +# failed_attempts: +# per_second: 0.17 +# burst_count: 3 +# +#rc_admin_redaction: +# per_second: 1 +# burst_count: 50 + + +# Ratelimiting settings for incoming federation +# +# The rc_federation configuration is made up of the following settings: +# - window_size: window size in milliseconds +# - sleep_limit: number of federation requests from a single server in +# a window before the server will delay processing the request. +# - sleep_delay: duration in milliseconds to delay processing events +# from remote servers by if they go over the sleep limit. +# - reject_limit: maximum number of concurrent federation requests +# allowed from a single server +# - concurrent: number of federation requests to concurrently process +# from a single server +# +# The defaults are as shown below. +# +#rc_federation: +# window_size: 1000 +# sleep_limit: 10 +# sleep_delay: 500 +# reject_limit: 50 +# concurrent: 3 + +# Target outgoing federation transaction frequency for sending read-receipts, +# per-room. +# +# If we end up trying to send out more read-receipts, they will get buffered up +# into fewer transactions. +# +#federation_rr_transactions_per_room_per_second: 50 + + + +## Media Store ## + +# Enable the media store service in the Synapse master. Uncomment the +# following if you are using a separate media store worker. +# +#enable_media_repo: false + +# Directory where uploaded images and attachments are stored. +# +media_store_path: "/data/media_store" + +# Media storage providers allow media to be stored in different +# locations. +# +#media_storage_providers: +# - module: file_system +# # Whether to write new local files. +# store_local: false +# # Whether to write new remote media +# store_remote: false +# # Whether to block upload requests waiting for write to this +# # provider to complete +# store_synchronous: false +# config: +# directory: /mnt/some/other/directory + +# Directory where in-progress uploads are stored. +# +uploads_path: "/data/uploads" + +# 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 thumbnails 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? +# +# 'false' by default: uncomment the following to enable it (and specify a +# url_preview_ip_range_blacklist blacklist). +# +#url_preview_enabled: true + +# 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. +# +# (0.0.0.0 and :: are always blacklisted, whether or not they are explicitly +# listed here, since they correspond to unroutable addresses.) +# +# This must be specified if url_preview_enabled is set. It is recommended that +# you uncomment the following list as a starting point. +# +#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' +# - '100.64.0.0/10' +# - '169.254.0.0/16' +# - '::1/128' +# - 'fe80::/64' +# - 'fc00::/7' + +# 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 ## +# See docs/CAPTCHA_SETUP for full details of configuring this. + +# 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.recaptcha.net/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" + +# The Username and password if the TURN server needs them and +# does not use a token +# +#turn_username: "TURNSERVER_USERNAME" +#turn_password: "TURNSERVER_PASSWORD" + +# How long generated TURN credentials last +# +#turn_user_lifetime: 1h + +# Whether guests should be allowed to use the TURN server. +# This defaults to True, otherwise VoIP will be unreliable for guests. +# However, it does introduce a slight security risk as it allows users to +# connect to arbitrary endpoints without having first signed up for a +# valid account (e.g. by passing a CAPTCHA). +# +#turn_allow_guests: True + + +## Registration ## +# +# Registration can be rate-limited using the parameters in the "Ratelimiting" +# section of this file. + +# Enable registration for new users. +# +#enable_registration: false + +# Optional account validity configuration. This allows for accounts to be denied +# any request after a given period. +# +# ``enabled`` defines whether the account validity feature is enabled. Defaults +# to False. +# +# ``period`` allows setting the period after which an account is valid +# after its registration. When renewing the account, its validity period +# will be extended by this amount of time. This parameter is required when using +# the account validity feature. +# +# ``renew_at`` is the amount of time before an account's expiry date at which +# Synapse will send an email to the account's email address with a renewal link. +# This needs the ``email`` and ``public_baseurl`` configuration sections to be +# filled. +# +# ``renew_email_subject`` is the subject of the email sent out with the renewal +# link. ``%(app)s`` can be used as a placeholder for the ``app_name`` parameter +# from the ``email`` section. +# +# Once this feature is enabled, Synapse will look for registered users without an +# expiration date at startup and will add one to every account it found using the +# current settings at that time. +# This means that, if a validity period is set, and Synapse is restarted (it will +# then derive an expiration date from the current validity period), and some time +# after that the validity period changes and Synapse is restarted, the users' +# expiration dates won't be updated unless their account is manually renewed. This +# date will be randomly selected within a range [now + period - d ; now + period], +# where d is equal to 10% of the validity period. +# +#account_validity: +# enabled: True +# period: 6w +# renew_at: 1w +# renew_email_subject: "Renew your %(app)s account" +# # Directory in which Synapse will try to find the HTML files to serve to the +# # user when trying to renew an account. Optional, defaults to +# # synapse/res/templates. +# template_dir: "res/templates" +# # HTML to be displayed to the user after they successfully renewed their +# # account. Optional. +# account_renewed_html_path: "account_renewed.html" +# # HTML to be displayed when the user tries to renew an account with an invalid +# # renewal token. Optional. +# invalid_token_html_path: "invalid_token.html" + +# Time that a user's session remains valid for, after they log in. +# +# Note that this is not currently compatible with guest logins. +# +# Note also that this is calculated at login time: changes are not applied +# retrospectively to users who have already logged in. +# +# By default, this is infinite. +# +#session_lifetime: 24h + +# The user must provide all of the below types of 3PID when registering. +# +#registrations_require_3pid: +# - email +# - msisdn + +# Explicitly disable asking for MSISDNs from the registration +# flow (overrides registrations_require_3pid if MSISDNs are set as required) +# +#disable_msisdn_registration: true + +# Mandate that users are only allowed to associate certain formats of +# 3PIDs with accounts on this server. +# +#allowed_local_3pids: +# - medium: email +# pattern: '.*@matrix\.org' +# - medium: email +# pattern: '.*@vector\.im' +# - medium: msisdn +# pattern: '\+44' + +# Enable 3PIDs lookup requests to identity servers from this server. +# +#enable_3pid_lookup: true + +# If set, allows registration of standard or admin accounts by anyone who +# has the shared secret, even if registration is otherwise disabled. +# +registration_shared_secret: "qEfwo92udsW8^r5F9CUMTgmjL,bskmb7~M5zC966bQ,3yJ&BtZ" + +# 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 is 12 (which equates to 2^12 rounds). +# N.B. that increasing this will exponentially increase the time required +# to register or login - e.g. 24 => 2^24 rounds which will take >20 mins. +# +#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 identity server which we suggest that clients should use when users log +# in on this server. +# +# (By default, no suggestion is made, so it is left up to the client. +# This setting is ignored unless public_baseurl is also set.) +# +#default_identity_server: https://matrix.org + +# The list of identity servers trusted to verify third party +# identifiers by this server. +# +# Also defines the ID server which will be called when an account is +# deactivated (one will be picked arbitrarily). +# +# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity +# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a +# background migration script, informing itself that the identity server all of its +# 3PIDs have been bound to is likely one of the below. +# +# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and +# it is now solely used for the purposes of the background migration script, and can be +# removed once it has run. +#trusted_third_party_id_servers: +# - matrix.org +# - vector.im + +# Handle threepid (email/phone etc) registration and password resets through a set of +# *trusted* identity servers. Note that this allows the configured identity server to +# reset passwords for accounts! +# +# Be aware that if `email` is not set, and SMTP options have not been +# configured in the email config block, registration and user password resets via +# email will be globally disabled. +# +# Additionally, if `msisdn` is not set, registration and password resets via msisdn +# will be disabled regardless. This is due to Synapse currently not supporting any +# method of sending SMS messages on its own. +# +# To enable using an identity server for operations regarding a particular third-party +# identifier type, set the value to the URL of that identity server as shown in the +# examples below. +# +# Servers handling the these requests must answer the `/requestToken` endpoints defined +# by the Matrix Identity Service API specification: +# https://matrix.org/docs/spec/identity_service/latest +# +# If a delegate is specified, the config option public_baseurl must also be filled out. +# +account_threepid_delegates: + #email: https://example.com # Delegate email sending to example.org + #msisdn: http://localhost:8090 # Delegate SMS sending to this local process + +# Users who register on this homeserver will automatically be joined +# to these rooms +# +#auto_join_rooms: +# - "#example:example.com" + +# Where auto_join_rooms are specified, setting this flag ensures that the +# the rooms exist by creating them when the first user on the +# homeserver registers. +# Setting to false means that if the rooms are not manually created, +# users cannot be auto-joined since they do not exist. +# +#autocreate_auto_join_rooms: true + + +## Metrics ### + +# Enable collection and rendering of performance metrics +# +#enable_metrics: False + +# Enable sentry integration +# NOTE: While attempts are made to ensure that the logs don't contain +# any sensitive information, this cannot be guaranteed. By enabling +# this option the sentry server may therefore receive sensitive +# information, and it in turn may then diseminate sensitive information +# through insecure notification channels if so configured. +# +#sentry: +# dsn: "..." + +# Flags to enable Prometheus metrics which are not suitable to be +# enabled by default, either for performance reasons or limited use. +# +metrics_flags: + # Publish synapse_federation_known_servers, a g auge of the number of + # servers this homeserver knows about, including itself. May cause + # performance problems on large homeservers. + # + #known_servers: true + +# Whether or not to report anonymized homeserver usage statistics. +report_stats: false + +# The endpoint to report the anonymized homeserver usage statistics to. +# Defaults to https://matrix.org/report-usage-stats/push +# +#report_stats_endpoint: https://example.com/report-usage-stats/push + + +## 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.encryption" +# - "m.room.name" + + +# A list of application service config files to use +# +#app_service_config_files: +# - app_service_1.yaml +# - app_service_2.yaml + +# Uncomment to enable tracking of application service IP addresses. Implicitly +# enables MAU tracking for application service users. +# +#track_appservice_user_ips: True + + +# a secret which is used to sign access tokens. If none is specified, +# the registration_shared_secret is used, if one is given; otherwise, +# a secret key is derived from the signing key. +# +macaroon_secret_key: "HzuXqF=NYJtLzj7CP=na;:+&HVbAT@8YNs4D*js+r3eZI4ZahO" + +# a secret which is used to calculate HMACs for form values, to stop +# falsification of values. Must be specified for the User Consent +# forms to work. +# +form_secret: "FHg2wJ_30pv^nuCxBhmS-dwk*lZwiGEY,:+@C;GQEEU_MxcbDz" + +## Signing Keys ## + +# Path to the signing key to sign messages with +# +signing_key_path: "/data/myserver.invalid.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 + +# The trusted servers to download signing keys from. +# +# When we need to fetch a signing key, each server is tried in parallel. +# +# Normally, the connection to the key server is validated via TLS certificates. +# Additional security can be provided by configuring a `verify key`, which +# will make synapse check that the response is signed by that key. +# +# This setting supercedes an older setting named `perspectives`. The old format +# is still supported for backwards-compatibility, but it is deprecated. +# +# 'trusted_key_servers' defaults to matrix.org, but using it will generate a +# warning on start-up. To suppress this warning, set +# 'suppress_key_server_warning' to true. +# +# Options for each entry in the list include: +# +# server_name: the name of the server. required. +# +# verify_keys: an optional map from key id to base64-encoded public key. +# If specified, we will check that the response is signed by at least +# one of the given keys. +# +# accept_keys_insecurely: a boolean. Normally, if `verify_keys` is unset, +# and federation_verify_certificates is not `true`, synapse will refuse +# to start, because this would allow anyone who can spoof DNS responses +# to masquerade as the trusted key server. If you know what you are doing +# and are sure that your network environment provides a secure connection +# to the key server, you can set this to `true` to override this +# behaviour. +# +# An example configuration might look like: +# +#trusted_key_servers: +# - server_name: "my_trusted_server.example.com" +# verify_keys: +# "ed25519:auto": "abcdefghijklmnopqrstuvwxyzabcdefghijklmopqr" +# - server_name: "my_other_trusted_server.example.com" +# +trusted_key_servers: + - server_name: "matrix.org" + +# Uncomment the following to disable the warning that is emitted when the +# trusted_key_servers include 'matrix.org'. See above. +# +#suppress_key_server_warning: true + +# The signing keys to use when acting as a trusted key server. If not specified +# defaults to the server signing key. +# +# Can contain multiple keys, one per line. +# +#key_server_signing_keys_path: "key_server_signing_keys.key" + + +# Enable SAML2 for registration and login. Uses pysaml2. +# +# At least one of `sp_config` or `config_path` must be set in this section to +# enable SAML login. +# +# (You will probably also want to set the following options to `false` to +# disable the regular login/registration flows: +# * enable_registration +# * password_config.enabled +# +# Once SAML support is enabled, a metadata file will be exposed at +# https://:/_matrix/saml2/metadata.xml, which you may be able to +# use to configure your SAML IdP with. Alternatively, you can manually configure +# the IdP to use an ACS location of +# https://:/_matrix/saml2/authn_response. +# +saml2_config: + # `sp_config` is the configuration for the pysaml2 Service Provider. + # See pysaml2 docs for format of config. + # + # Default values will be used for the 'entityid' and 'service' settings, + # so it is not normally necessary to specify them unless you need to + # override them. + # + #sp_config: + # # point this to the IdP's metadata. You can use either a local file or + # # (preferably) a URL. + # metadata: + # #local: ["saml2/idp.xml"] + # remote: + # - url: https://our_idp/metadata.xml + # + # # By default, the user has to go to our login page first. If you'd like + # # to allow IdP-initiated login, set 'allow_unsolicited: True' in a + # # 'service.sp' section: + # # + # #service: + # # sp: + # # allow_unsolicited: true + # + # # The examples below are just used to generate our metadata xml, and you + # # may well not need them, depending on your setup. Alternatively you + # # may need a whole lot more detail - see the pysaml2 docs! + # + # description: ["My awesome SP", "en"] + # name: ["Test SP", "en"] + # + # organization: + # name: Example com + # display_name: + # - ["Example co", "en"] + # url: "http://example.com" + # + # contact_person: + # - given_name: Bob + # sur_name: "the Sysadmin" + # email_address": ["admin@example.com"] + # contact_type": technical + + # Instead of putting the config inline as above, you can specify a + # separate pysaml2 configuration file: + # + #config_path: "/data/sp_conf.py" + + # the lifetime of a SAML session. This defines how long a user has to + # complete the authentication process, if allow_unsolicited is unset. + # The default is 5 minutes. + # + #saml_session_lifetime: 5m + + # The SAML attribute (after mapping via the attribute maps) to use to derive + # the Matrix ID from. 'uid' by default. + # + #mxid_source_attribute: displayName + + # The mapping system to use for mapping the saml attribute onto a matrix ID. + # Options include: + # * 'hexencode' (which maps unpermitted characters to '=xx') + # * 'dotreplace' (which replaces unpermitted characters with '.'). + # The default is 'hexencode'. + # + #mxid_mapping: dotreplace + + # In previous versions of synapse, the mapping from SAML attribute to MXID was + # always calculated dynamically rather than stored in a table. For backwards- + # compatibility, we will look for user_ids matching such a pattern before + # creating a new account. + # + # This setting controls the SAML attribute which will be used for this + # backwards-compatibility lookup. Typically it should be 'uid', but if the + # attribute maps are changed, it may be necessary to change it. + # + # The default is 'uid'. + # + #grandfathered_mxid_source_attribute: upn + + + +# Enable CAS for registration and login. +# +#cas_config: +# enabled: true +# server_url: "https://cas-server.com" +# service_url: "https://homeserver.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" + + +password_config: + # Uncomment to disable password login + # + #enabled: false + + # Uncomment to disable authentication against the local password + # database. This is ignored if `enabled` is false, and is only useful + # if you have other password_providers. + # + #localdb_enabled: false + + # Uncomment and change to a secret random string for extra security. + # DO NOT CHANGE THIS AFTER INITIAL SETUP! + # + #pepper: "EVEN_MORE_SECRET" + + + +# Enable sending emails for password resets, notification events or +# account expiry notices +# +# If your SMTP server requires authentication, the optional smtp_user & +# smtp_pass variables should be used +# +#email: +# enable_notifs: false +# smtp_host: "localhost" +# smtp_port: 25 # SSL: 465, STARTTLS: 587 +# smtp_user: "exampleusername" +# smtp_pass: "examplepassword" +# require_transport_security: False +# notif_from: "Your Friendly %(app)s Home Server " +# app_name: Matrix +# +# # Enable email notifications by default +# # +# notif_for_new_users: True +# +# # Defining a custom URL for Riot is only needed if email notifications +# # should contain links to a self-hosted installation of Riot; when set +# # the "app_name" setting is ignored +# # +# riot_base_url: "http://localhost/riot" +# +# # Configure the time that a validation email or text message code +# # will expire after sending +# # +# # This is currently used for password resets +# # +# #validation_token_lifetime: 1h +# +# # Template directory. All template files should be stored within this +# # directory. If not set, default templates from within the Synapse +# # package will be used +# # +# # For the list of default templates, please see +# # https://github.com/matrix-org/synapse/tree/master/synapse/res/templates +# # +# #template_dir: res/templates +# +# # Templates for email notifications +# # +# notif_template_html: notif_mail.html +# notif_template_text: notif_mail.txt +# +# # Templates for account expiry notices +# # +# expiry_template_html: notice_expiry.html +# expiry_template_text: notice_expiry.txt +# +# # Templates for password reset emails sent by the homeserver +# # +# #password_reset_template_html: password_reset.html +# #password_reset_template_text: password_reset.txt +# +# # Templates for registration emails sent by the homeserver +# # +# #registration_template_html: registration.html +# #registration_template_text: registration.txt +# +# # Templates for validation emails sent by the homeserver when adding an email to +# # your user account +# # +# #add_threepid_template_html: add_threepid.html +# #add_threepid_template_text: add_threepid.txt +# +# # Templates for password reset success and failure pages that a user +# # will see after attempting to reset their password +# # +# #password_reset_template_success_html: password_reset_success.html +# #password_reset_template_failure_html: password_reset_failure.html +# +# # Templates for registration success and failure pages that a user +# # will see after attempting to register using an email or phone +# # +# #registration_template_success_html: registration_success.html +# #registration_template_failure_html: registration_failure.html +# +# # Templates for success and failure pages that a user will see after attempting +# # to add an email or phone to their account +# # +# #add_threepid_success_html: add_threepid_success.html +# #add_threepid_failure_html: add_threepid_failure.html + + +#password_providers: +# - module: "ldap_auth_provider.LdapAuthProvider" +# config: +# enabled: true +# uri: "ldap://ldap.example.com:389" +# start_tls: true +# base: "ou=users,dc=example,dc=com" +# attributes: +# uid: "cn" +# mail: "email" +# name: "givenName" +# #bind_dn: +# #bind_password: +# #filter: "(objectClass=posixAccount)" + + + +# Clients requesting push notifications can either have the body of +# the message sent in the notification poke along with other details +# like the sender, or just the event ID and room ID (`event_id_only`). +# If clients choose the former, this option controls whether the +# notification request includes the content of the event (other details +# like the sender are still included). For `event_id_only` push, it +# has no effect. +# +# For modern android devices the notification content will still appear +# because it is loaded by the app. iPhone, however will send a +# notification saying only that a message arrived and who it came from. +# +#push: +# include_content: true + + +#spam_checker: +# module: "my_custom_project.SuperSpamChecker" +# config: +# example_option: 'things' + + +# Uncomment to allow non-server-admin users to create groups on this server +# +#enable_group_creation: true + +# If enabled, non server admins can only create groups with local parts +# starting with this prefix +# +#group_creation_prefix: "unofficial/" + + + +# User Directory configuration +# +# 'enabled' defines whether users can search the user directory. If +# false then empty responses are returned to all queries. Defaults to +# true. +# +# 'search_all_users' defines whether to search all users visible to your HS +# when searching the user directory, rather than limiting to users visible +# in public rooms. Defaults to false. If you set it True, you'll have to +# rebuild the user_directory search indexes, see +# https://github.com/matrix-org/synapse/blob/master/docs/user_directory.md +# +#user_directory: +# enabled: true +# search_all_users: false + + +# User Consent configuration +# +# for detailed instructions, see +# https://github.com/matrix-org/synapse/blob/master/docs/consent_tracking.md +# +# Parts of this section are required if enabling the 'consent' resource under +# 'listeners', in particular 'template_dir' and 'version'. +# +# 'template_dir' gives the location of the templates for the HTML forms. +# This directory should contain one subdirectory per language (eg, 'en', 'fr'), +# and each language directory should contain the policy document (named as +# '.html') and a success page (success.html). +# +# 'version' specifies the 'current' version of the policy document. It defines +# the version to be served by the consent resource if there is no 'v' +# parameter. +# +# 'server_notice_content', if enabled, will send a user a "Server Notice" +# asking them to consent to the privacy policy. The 'server_notices' section +# must also be configured for this to work. Notices will *not* be sent to +# guest users unless 'send_server_notice_to_guests' is set to true. +# +# 'block_events_error', if set, will block any attempts to send events +# until the user consents to the privacy policy. The value of the setting is +# used as the text of the error. +# +# 'require_at_registration', if enabled, will add a step to the registration +# process, similar to how captcha works. Users will be required to accept the +# policy before their account is created. +# +# 'policy_name' is the display name of the policy users will see when registering +# for an account. Has no effect unless `require_at_registration` is enabled. +# Defaults to "Privacy Policy". +# +#user_consent: +# template_dir: res/templates/privacy +# version: 1.0 +# server_notice_content: +# msgtype: m.text +# body: >- +# To continue using this homeserver you must review and agree to the +# terms and conditions at %(consent_uri)s +# send_server_notice_to_guests: True +# block_events_error: >- +# To continue using this homeserver you must review and agree to the +# terms and conditions at %(consent_uri)s +# require_at_registration: False +# policy_name: Privacy Policy +# + + + +# Local statistics collection. Used in populating the room directory. +# +# 'bucket_size' controls how large each statistics timeslice is. It can +# be defined in a human readable short form -- e.g. "1d", "1y". +# +# 'retention' controls how long historical statistics will be kept for. +# It can be defined in a human readable short form -- e.g. "1d", "1y". +# +# +#stats: +# enabled: true +# bucket_size: 1d +# retention: 1y + + +# Server Notices room configuration +# +# Uncomment this section to enable a room which can be used to send notices +# from the server to users. It is a special room which cannot be left; notices +# come from a special "notices" user id. +# +# If you uncomment this section, you *must* define the system_mxid_localpart +# setting, which defines the id of the user which will be used to send the +# notices. +# +# It's also possible to override the room name, the display name of the +# "notices" user, and the avatar for the user. +# +#server_notices: +# system_mxid_localpart: notices +# system_mxid_display_name: "Server Notices" +# system_mxid_avatar_url: "mxc://server.com/oumMVlgDnLYFaPVkExemNVVZ" +# room_name: "Server Notices" + + + +# Uncomment to disable searching the public room list. When disabled +# blocks searching local and remote room lists for local and remote +# users by always returning an empty list for all queries. +# +#enable_room_list_search: false + +# The `alias_creation` option controls who's allowed to create aliases +# on this server. +# +# The format of this option is a list of rules that contain globs that +# match against user_id, room_id and the new alias (fully qualified with +# server name). The action in the first rule that matches is taken, +# which can currently either be "allow" or "deny". +# +# Missing user_id/room_id/alias fields default to "*". +# +# If no rules match the request is denied. An empty list means no one +# can create aliases. +# +# Options for the rules include: +# +# user_id: Matches against the creator of the alias +# alias: Matches against the alias being created +# room_id: Matches against the room ID the alias is being pointed at +# action: Whether to "allow" or "deny" the request if the rule matches +# +# The default is: +# +#alias_creation_rules: +# - user_id: "*" +# alias: "*" +# room_id: "*" +# action: allow + +# The `room_list_publication_rules` option controls who can publish and +# which rooms can be published in the public room list. +# +# The format of this option is the same as that for +# `alias_creation_rules`. +# +# If the room has one or more aliases associated with it, only one of +# the aliases needs to match the alias rule. If there are no aliases +# then only rules with `alias: *` match. +# +# If no rules match the request is denied. An empty list means no one +# can publish rooms. +# +# Options for the rules include: +# +# user_id: Matches agaisnt the creator of the alias +# room_id: Matches against the room ID being published +# alias: Matches against any current local or canonical aliases +# associated with the room +# action: Whether to "allow" or "deny" the request if the rule matches +# +# The default is: +# +#room_list_publication_rules: +# - user_id: "*" +# alias: "*" +# room_id: "*" +# action: allow + + +# Server admins can define a Python module that implements extra rules for +# allowing or denying incoming events. In order to work, this module needs to +# override the methods defined in synapse/events/third_party_rules.py. +# +# This feature is designed to be used in closed federations only, where each +# participating server enforces the same rules. +# +#third_party_event_rules: +# module: "my_custom_project.SuperRulesSet" +# config: +# example_option: 'things' + + +## Opentracing ## + +# These settings enable opentracing, which implements distributed tracing. +# This allows you to observe the causal chains of events across servers +# including requests, key lookups etc., across any server running +# synapse or any other other services which supports opentracing +# (specifically those implemented with Jaeger). +# +opentracing: + # tracing is disabled by default. Uncomment the following line to enable it. + # + #enabled: true + + # The list of homeservers we wish to send and receive span contexts and span baggage. + # See docs/opentracing.rst + # This is a list of regexes which are matched against the server_name of the + # homeserver. + # + # By defult, it is empty, so no servers are matched. + # + #homeserver_whitelist: + # - ".*" + + # Jaeger can be configured to sample traces at different rates. + # All configuration options provided by Jaeger can be set here. + # Jaeger's configuration mostly related to trace sampling which + # is documented here: + # https://www.jaegertracing.io/docs/1.13/sampling/. + # + #jaeger_config: + # sampler: + # type: const + # param: 1 + + # Logging whether spans were started and reported + # + # logging: + # false diff --git a/templates/homeserver.yaml.j2 b/templates/homeserver.yaml.j2 new file mode 100644 index 0000000..c1110f0 --- /dev/null +++ b/templates/homeserver.yaml.j2 @@ -0,0 +1,209 @@ +# vim:ft=yaml + +## TLS ## + +{% if not SYNAPSE_NO_TLS %} + +tls_certificate_path: "/data/{{ SYNAPSE_SERVER_NAME }}.tls.crt" +tls_private_key_path: "/data/{{ SYNAPSE_SERVER_NAME }}.tls.key" + +{% if SYNAPSE_ACME %} +acme: + enabled: true + port: 8009 +{% endif %} + +{% endif %} + +## Server ## + +server_name: "{{ SYNAPSE_SERVER_NAME }}" +pid_file: /homeserver.pid +web_client: False +soft_file_limit: 0 +log_config: "{{ SYNAPSE_LOG_CONFIG }}" + +## Ports ## + +listeners: + {% if not SYNAPSE_NO_TLS %} + - + port: 8448 + bind_addresses: ['::'] + type: http + tls: true + x_forwarded: false + resources: + - names: [client] + compress: true + - names: [federation] # Federation APIs + compress: false + {% endif %} + + - port: 8008 + tls: false + bind_addresses: ['::'] + type: http + x_forwarded: false + + resources: + - names: [client] + compress: true + - names: [federation] + compress: false + +## Database ## + +{% if POSTGRES_PASSWORD %} +database: + name: "psycopg2" + args: + user: "{{ POSTGRES_USER or "synapse" }}" + password: "{{ POSTGRES_PASSWORD }}" + database: "{{ POSTGRES_DB or "synapse" }}" + host: "{{ POSTGRES_HOST or "db" }}" + port: "{{ POSTGRES_PORT or "5432" }}" + cp_min: 5 + cp_max: 10 +{% else %} +database: + name: "sqlite3" + args: + database: "/data/homeserver.db" +{% endif %} + +## Performance ## + +event_cache_size: "{{ SYNAPSE_EVENT_CACHE_SIZE or "10K" }}" + +## Ratelimiting ## + +rc_messages_per_second: 0.2 +rc_message_burst_count: 10.0 +federation_rc_window_size: 1000 +federation_rc_sleep_limit: 10 +federation_rc_sleep_delay: 500 +federation_rc_reject_limit: 50 +federation_rc_concurrent: 3 + +## Files ## + +media_store_path: "/data/media" +uploads_path: "/data/uploads" +max_upload_size: "{{ SYNAPSE_MAX_UPLOAD_SIZE or "10M" }}" +max_image_pixels: "32M" +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 + +url_preview_enabled: False +max_spider_size: "10M" + +## Captcha ## + +{% if SYNAPSE_RECAPTCHA_PUBLIC_KEY %} +recaptcha_public_key: "{{ SYNAPSE_RECAPTCHA_PUBLIC_KEY }}" +recaptcha_private_key: "{{ SYNAPSE_RECAPTCHA_PRIVATE_KEY }}" +enable_registration_captcha: True +recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify" +{% else %} +recaptcha_public_key: "YOUR_PUBLIC_KEY" +recaptcha_private_key: "YOUR_PRIVATE_KEY" +enable_registration_captcha: False +recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify" +{% endif %} + +## Turn ## + +{% if SYNAPSE_TURN_URIS %} +turn_uris: +{% for uri in SYNAPSE_TURN_URIS.split(',') %} - "{{ uri }}" +{% endfor %} +turn_shared_secret: "{{ SYNAPSE_TURN_SECRET }}" +turn_user_lifetime: "1h" +turn_allow_guests: True +{% else %} +turn_uris: [] +turn_shared_secret: "YOUR_SHARED_SECRET" +turn_user_lifetime: "1h" +turn_allow_guests: True +{% endif %} + +## Registration ## + +enable_registration: {{ "True" if SYNAPSE_ENABLE_REGISTRATION else "False" }} +registration_shared_secret: "{{ SYNAPSE_REGISTRATION_SHARED_SECRET }}" +bcrypt_rounds: 12 +allow_guest_access: {{ "True" if SYNAPSE_ALLOW_GUEST else "False" }} +enable_group_creation: true + +# The list of identity servers trusted to verify third party +# identifiers by this server. +# +# Also defines the ID server which will be called when an account is +# deactivated (one will be picked arbitrarily). +trusted_third_party_id_servers: + - matrix.org + - vector.im + +## Metrics ### + +{% if SYNAPSE_REPORT_STATS.lower() == "yes" %} +enable_metrics: True +report_stats: True +{% else %} +enable_metrics: False +report_stats: False +{% endif %} + +## API Configuration ## + +room_invite_state_types: + - "m.room.join_rules" + - "m.room.canonical_alias" + - "m.room.avatar" + - "m.room.name" + +{% if SYNAPSE_APPSERVICES %} +app_service_config_files: +{% for appservice in SYNAPSE_APPSERVICES %} - "{{ appservice }}" +{% endfor %} +{% else %} +app_service_config_files: [] +{% endif %} + +macaroon_secret_key: "{{ SYNAPSE_MACAROON_SECRET_KEY }}" +expire_access_token: False + +## Signing Keys ## + +signing_key_path: "/data/{{ SYNAPSE_SERVER_NAME }}.signing.key" +old_signing_keys: {} +key_refresh_interval: "1d" # 1 Day. + +# The trusted servers to download signing keys from. +perspectives: + servers: + "matrix.org": + verify_keys: + "ed25519:auto": + key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw" + +password_config: + enabled: true diff --git a/ubuntu-bionic-18.04-cloudimg-console.log b/ubuntu-bionic-18.04-cloudimg-console.log deleted file mode 100644 index e69de29..0000000 diff --git a/website.yml b/website.yml deleted file mode 100644 index 738d875..0000000 --- a/website.yml +++ /dev/null @@ -1 +0,0 @@ -# Static site deployment with Hugo? \ No newline at end of file