From 269f3b79974cfd0bf7e0dc85d33656c6405a3230 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Thu, 28 Nov 2019 02:09:17 +0100 Subject: [PATCH] scaleway config --- hosts.ini.example | 1 + main.yml | 2 +- matrix.yml | 49 +++++++++++++++++++++----- templates/docker-compose-matrix.yml.j2 | 46 +++++++----------------- 4 files changed, 55 insertions(+), 43 deletions(-) create mode 100644 hosts.ini.example diff --git a/hosts.ini.example b/hosts.ini.example new file mode 100644 index 0000000..a839358 --- /dev/null +++ b/hosts.ini.example @@ -0,0 +1 @@ + ansible_connection=ssh ansible_user=root ansible_password= ansible_host= ansible_become=yes \ No newline at end of file diff --git a/main.yml b/main.yml index 7ada3ff..d24a789 100644 --- a/main.yml +++ b/main.yml @@ -1,6 +1,6 @@ --- - hosts: - - sonic-preprod + - scaleway handlers: - name: reboot reboot: diff --git a/matrix.yml b/matrix.yml index c54f53e..e273434 100644 --- a/matrix.yml +++ b/matrix.yml @@ -1,11 +1,10 @@ --- -- hosts: synapse -# todo: create user for synapse +- hosts: scaleway vars: matrix_synapse_version: "v1.5.1-py3" # matrix_synapse_version: "v1.5.1" - matrix_server_name: matrix-sonic-beta.local - matrix_bind_address: "192.168.42.4" + matrix_server_name: matrix-test.local + matrix_bind_address: "51.158.114.109" matrix_synapse_pg_host: synapse-postgres # does it need to be an IP? matrix_synapse_db_name: psycopg2 @@ -14,7 +13,10 @@ matrix_synapse_pg_db: "synapse" matrix_registration_shared_secret: "xxxxx" matrix_synapse_report_stats: false - matrix_synapse_config_path: "/etc/matrix-synapse/homeserver.yaml" + matrix_synapse_config_dir: "/etc/matrix-synapse" + matrix_synapse_config_path: "{{ matrix_synapse_config_dir }}/homeserver.yaml" + matrix_synapse_config_docker_path: "/config/homeserver.yaml" + matrix_synapse_config_docker_dir: "/config" # to implement # matrix_no_tls: true @@ -22,18 +24,49 @@ tasks: # - docker_volume: # name: synapse-data + - name: Create config directory + file: + path: "{{ matrix_synapse_config_dir }}" + state: directory - template: - src: templates/synapse_homeserver.yaml.j2 - dest: {{ matrix_synapse_config_path }} + src: templates/homeserver.yaml.j2 + dest: "{{ matrix_synapse_config_path }}" + + - name: Create config directory + file: + path: "/etc/docker" + state: directory - template: src: templates/docker-compose-matrix.yml.j2 dest: /etc/docker/docker-compose.yml + + - name: Install required system packages + apt: name={{ item }} state=latest update_cache=yes + loop: [ 'apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common', 'python3-pip'] + + - name: Add Docker GPG apt Key + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + + - name: Add Docker Repository + apt_repository: + repo: deb https://download.docker.com/linux/ubuntu bionic stable + state: present + + - name: Update apt and install docker-ce + apt: update_cache=yes name=docker-ce state=latest + + - name: install pip docker + pip: name={{ item }} + loop: ['docker', 'docker-compose'] + - name: Create and start matrix services docker_compose: - project_src: matrix + project_src: /etc/docker/ register: output diff --git a/templates/docker-compose-matrix.yml.j2 b/templates/docker-compose-matrix.yml.j2 index 1a0d5b8..10c04f0 100644 --- a/templates/docker-compose-matrix.yml.j2 +++ b/templates/docker-compose-matrix.yml.j2 @@ -1,32 +1,27 @@ -# 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-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_pg_host: synapse-postgres + synapse: - {# build: - context: ../.. - dockerfile: docker/Dockerfile #} - image: "docker.io/matrixdotorg/synapse: {{ matrix_synapse_version }}" + # build: + # context: ../.. + # dockerfile: docker/Dockerfile + image: "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={{ matrix_synapse_config_path }} + - SYNAPSE_REPORT_STATS={{ matrix_synapse_report_stats }} + - SYNAPSE_CONFIG_PATH={{ matrix_synapse_config_docker_path }} volumes: # You may either store all the files in a local folder - - ./matrix-config:/etc/matrix-synapse + - {{ matrix_synapse_config_dir }}:{{ matrix_synapse_config_docker_dir }} - ./files:/data # .. or you may split this between different storage points # - ./files:/data @@ -38,25 +33,8 @@ services: # 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 #} - + # labels: + db: image: docker.io/postgres:10-alpine # Change that password, of course!