Start with move to postgres

This commit is contained in:
Mathias Teier 2021-01-17 17:37:14 +01:00
parent 82e6557f3c
commit 5be426f24f
14 changed files with 151 additions and 38 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
source ./.env
[ -z "$MARIADB_ROOT_PASSWORD" ] && echo "MARIADB_ROOT_PASSWORD not set" && exit 1
[ -z "$POSTGRES_PASSWORD" ] && echo "POSTGRESS_PASSWORD not set" && exit 1
[ -z "$NEXTCLOUD_DB_PASSWORD" ] && echo "NEXTCLOUD_DB_PASSWORD not set" && exit 1
ansible-playbook nextcloud/init.yml

View File

@ -0,0 +1,23 @@
version: '2.4'
services:
mautrix-signal:
image: dock.mau.dev/tulir/mautrix-signal:latest
restart: unless-stopped
volumes:
- /var/mautrix-signal:/data
- /var/signald:/signald
networks:
- matrix_net
- postgrs_net
signald:
image: docker.io/finn/signald:latest
restart: unless-stopped
volumes:
- /var/signald:/signald
networks:
matrix_net:
name: matrix_net
driver: bridge
postgres_net:
name: postgres_net
external: true

25
mautrix-signal/start.yml Normal file
View File

@ -0,0 +1,25 @@
---
- hosts: teier.eu
gather_facts: no
tasks:
- name: Check mautrix-signal directory
stat:
path: /dc/mautrix-signal
register: mautrix-signal_dc_dir_stat
- name: Create mautrix-signal dc directory
file:
path: /dc/mautrix-signal
state: directory
mode: 0755
group: root
owner: root
when: mautrix-signal_dc_dir_stat.islnk is not defined
- name: Copy compose file
copy:
src: docker-compose.yml
dest: /dc/mautrix-signal
- name: Start mautrix-signal
shell: "cd /dc/mautrix-signal && docker-compose up -d"

6
mautrix-signal/stop.yml Normal file
View File

@ -0,0 +1,6 @@
---
- hosts: teier.eu
gather_facts: no
tasks:
- name: Stop Mariadb
shell: "cd /dc/mariadb && docker-compose stop"

View File

@ -0,0 +1,6 @@
---
- hosts: teier.eu
gather_facts: no
tasks:
- name: Teardown mariadb
shell: "cd /dc/mariadb && docker-compose down"

View File

@ -3,10 +3,10 @@ services:
nextcloud:
image: nextcloud:fpm
environment:
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_HOST: mariadb
MYSQL_PASSWORD: ${NEXTCLOUD_DB_PASSWORD}
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_HOST: mariadb
POSTGRES_PASSWORD: ${POSTGRES_DB_PASSWORD}
TRUSTED_PROXIES: "cloud.teier.eu 138.201.74.231 172.0.0.1/8"
APACHE_DISABLE_REWRITE_IP: "1"
OVERWRITEHOST: "cloud.teier.eu"
@ -14,7 +14,7 @@ services:
OVERWRITEWEBROOT: "/"
OVERWRITECONADDR: "138.201.74.231"
networks:
- "mariadb_net"
- "postgres_net"
- "nextcloud_net"
volumes:
- /var/nextcloud:/var/www/html
@ -34,6 +34,5 @@ networks:
name: "nextcloud_net"
driver: bridge
mariadb_net:
name: "mariadb_net"
name: "postgres_net"
external: true

View File

@ -2,24 +2,21 @@
- hosts: teier.eu
gather_facts: no
tasks:
- name: Install PyMySQL
shell: pip install PyMySQL
- name: Create database for nextcloud
community.mysql.mysql_db:
login_user: root
login_password: "{{ lookup('env', 'MARIADB_ROOT_PASSWORD') }}"
community.postgresql.postgresql_db:
login_user: postgres
login_password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
name: nextcloud
state: present
- name: Create database user for nextcloud
community.mysql.mysql_user:
login_user: root
login_password: "{{ lookup('env', 'MARIADB_ROOT_PASSWORD') }}"
community.postgresql.postgresql_user::
login_user: postgres
login_password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
name: nextcloud
password: "{{ lookup('env', 'NEXTCLOUD_DB_PASSWORD') }}"
host: "%"
priv: 'nextcloud.*:ALL'
db: nextcloud
priv: 'ALL'
state: present
- name: Check dc directory

View File

@ -1,9 +1,9 @@
version: '2.4'
services:
nummus:
image: glenroy37/nummus:0.1.1-alpha
image: glenroy37/nummus:0.1.2-alpha
environment:
DB_HOST: mariadb
DB_HOST: postgres
DB_USER: nummus
DB_PASSWORD: ${NUMMUS_DB_PASSWORD}
DB_NAME: nummus
@ -16,6 +16,5 @@ services:
- 8082:80
networks:
mariadb_net:
name: "mariadb_net"
name: "postgres_net"
external: true

View File

@ -2,24 +2,21 @@
- hosts: teier.eu
gather_facts: no
tasks:
- name: Install PyMySQL
shell: pip install PyMySQL
- name: Create database for Nummus
community.mysql.mysql_db:
community.postgresql.postgresql_db
login_user: root
login_password: "{{ lookup('env', 'MARIADB_ROOT_PASSWORD') }}"
login_password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
name: nummus
state: present
- name: Create database user for Nummus
community.mysql.mysql_user:
login_user: root
login_password: "{{ lookup('env', 'MARIADB_ROOT_PASSWORD') }}"
host: "%"
community.postgresql.postgresql_user:
login_user: postgres
login_password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
name: "nummus"
db: nummus
password: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}"
priv: 'nummus.*:ALL'
priv: 'ALL'
state: present
- name: Check dc directory

View File

@ -0,0 +1,17 @@
version: '2.4'
services:
postgres:
image: postgres:13.1-alpine
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
PGDATA: /var/lib/postgresql/data/pgdata
networks:
- postgres_net
volumes:
- /var/lib/postgresql/data:/var/lib/postgresql/data
ports:
- 5432:5432
networks:
mariadb_net:
name: postgres_net
driver: bridge

27
postgres/start.yml Normal file
View File

@ -0,0 +1,27 @@
---
- hosts: teier.eu
gather_facts: no
tasks:
- name: Check dc directory
stat:
path: /dc/postgres
register: postgres_dc_dir_stat
- name: Create mariadb dc directory
file:
path: /dc/postgres
state: directory
mode: 0755
group: root
owner: root
when: postgres_dc_dir_stat.islnk is not defined
- name: Copy compose file
copy:
src: docker-compose.yml
dest: /dc/postgres
- name: Start postgres
shell: "cd /dc/mariadb && docker-compose up -d"
environment:
POSTGRES_PASSWORD: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"

6
postgres/stop.yml Normal file
View File

@ -0,0 +1,6 @@
---
- hosts: teier.eu
gather_facts: no
tasks:
- name: Stop Postgres
shell: "cd /dc/postgres && docker-compose stop"

6
postgres/teardown.yml Normal file
View File

@ -0,0 +1,6 @@
---
- hosts: teier.eu
gather_facts: no
tasks:
- name: Teardown Postgres
shell: "cd /dc/postgres && docker-compose down"

5
start-postgres.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
source ./.env
[ -z "$POSTGRES_PASSWORD" ] && echo "POSTGRES_PASSWORD not set" && exit 1
ansible-playbook postgres/start.yml