Use Postgres 10.x by default (only for new installs)

This playbook just tries to avoid trying to setup a Postgres 10
database with existing 9.x files, as that makes Postgres complain.

Due to this, existing installs (still on 9.x) are detected
and left on Postgres 9.x.
They need to be upgraded to Postgres 10.x manually.
This commit is contained in:
Slavi Pantaleev 2018-05-28 14:47:09 +03:00
parent f1b4730e82
commit cbee084ac1
4 changed files with 38 additions and 4 deletions

View file

@ -40,7 +40,11 @@ matrix_coturn_base_path: "{{ matrix_base_data_path }}/coturn"
matrix_coturn_config_path: "{{ matrix_coturn_base_path }}/turnserver.conf" matrix_coturn_config_path: "{{ matrix_coturn_base_path }}/turnserver.conf"
matrix_scratchpad_dir: "{{ matrix_base_data_path }}/scratchpad" matrix_scratchpad_dir: "{{ matrix_base_data_path }}/scratchpad"
docker_postgres_image: "postgres:9.6.8-alpine"
docker_postgres_image_v9: "postgres:9.6.8-alpine"
docker_postgres_image_v10: "postgres:10.4-alpine"
docker_postgres_image_latest: "{{ docker_postgres_image_v10 }}"
docker_matrix_image: "matrixdotorg/synapse:v0.30.0" docker_matrix_image: "matrixdotorg/synapse:v0.30.0"
docker_nginx_image: "nginx:1.13.12-alpine" docker_nginx_image: "nginx:1.13.12-alpine"
docker_riot_image: "avhost/docker-matrix-riot:v0.15.4" docker_riot_image: "avhost/docker-matrix-riot:v0.15.4"
@ -48,6 +52,7 @@ docker_s3fs_image: "xueshanf/s3fs:latest"
docker_goofys_image: "cloudproto/goofys:latest" docker_goofys_image: "cloudproto/goofys:latest"
docker_coturn_image: "instrumentisto/coturn:4.5.0.7" docker_coturn_image: "instrumentisto/coturn:4.5.0.7"
# To avoid Synapse's macaroon secret key from changing every time # To avoid Synapse's macaroon secret key from changing every time
# a new config is built from scratch, you can specify one here. # a new config is built from scratch, you can specify one here.
matrix_synapse_macaroon_secret_key: null matrix_synapse_macaroon_secret_key: null

View file

@ -4,10 +4,39 @@
# Generic tasks, no matter what kind of server we're using (internal/external) # Generic tasks, no matter what kind of server we're using (internal/external)
# #
- name: Determine existing Postgres version (check PG_VERSION file)
stat:
path: "{{ matrix_postgres_data_path }}/PG_VERSION"
register: result_pg_version_stat
- name: Determine existing Postgres version (read PG_VERSION file)
slurp:
src: "{{ matrix_postgres_data_path }}/PG_VERSION"
register: result_pg_version
when: "result_pg_version_stat.stat.exists"
- name: Determine existing Postgres version (default to empty)
set_fact:
pg_version: ""
- name: Determine existing Postgres version (make sense of PG_VERSION file)
set_fact:
pg_version: "{{ result_pg_version['content']|b64decode|replace('\n', '') }}"
when: "result_pg_version_stat.stat.exists"
- name: Determine Postgres version to use (default to latest)
set_fact:
docker_postgres_image_to_use: "{{ docker_postgres_image_latest }}"
- name: Determine Postgres version to use (use 9.x, if detected)
set_fact:
docker_postgres_image_to_use: "{{ docker_postgres_image_v9 }}"
when: "pg_version.startswith('9.')"
# Even if we don't run the internal server, we still need this for running the CLI # Even if we don't run the internal server, we still need this for running the CLI
- name: Ensure postgres Docker image is pulled - name: Ensure postgres Docker image is pulled
docker_image: docker_image:
name: "{{ docker_postgres_image }}" name: "{{ docker_postgres_image_to_use }}"
- name: Ensure Postgres environment variables file created - name: Ensure Postgres environment variables file created
template: template:

View file

@ -14,7 +14,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-postgres \
--env-file={{ matrix_environment_variables_data_path }}/env-postgres-server-docker \ --env-file={{ matrix_environment_variables_data_path }}/env-postgres-server-docker \
-v {{ matrix_postgres_data_path }}:/var/lib/postgresql/data \ -v {{ matrix_postgres_data_path }}:/var/lib/postgresql/data \
-v /etc/passwd:/etc/passwd:ro \ -v /etc/passwd:/etc/passwd:ro \
{{ docker_postgres_image }} {{ docker_postgres_image_to_use }}
ExecStop=-/usr/bin/docker stop matrix-postgres ExecStop=-/usr/bin/docker stop matrix-postgres
ExecStop=-/usr/bin/docker rm matrix-postgres ExecStop=-/usr/bin/docker rm matrix-postgres
Restart=always Restart=always

View file

@ -7,5 +7,5 @@ docker run \
{% if not matrix_postgres_use_external %} {% if not matrix_postgres_use_external %}
--link=matrix-postgres:{{ matrix_postgres_connection_hostname }} \ --link=matrix-postgres:{{ matrix_postgres_connection_hostname }} \
{% endif %} {% endif %}
{{ docker_postgres_image }} \ {{ docker_postgres_image_to_use }} \
psql -h {{ matrix_postgres_connection_hostname }} psql -h {{ matrix_postgres_connection_hostname }}