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 #!/bin/bash
source ./.env 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 [ -z "$NEXTCLOUD_DB_PASSWORD" ] && echo "NEXTCLOUD_DB_PASSWORD not set" && exit 1
ansible-playbook nextcloud/init.yml 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: nextcloud:
image: nextcloud:fpm image: nextcloud:fpm
environment: environment:
MYSQL_DATABASE: nextcloud POSTGRES_DB: nextcloud
MYSQL_USER: nextcloud POSTGRES_USER: nextcloud
MYSQL_HOST: mariadb POSTGRES_HOST: mariadb
MYSQL_PASSWORD: ${NEXTCLOUD_DB_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_DB_PASSWORD}
TRUSTED_PROXIES: "cloud.teier.eu 138.201.74.231 172.0.0.1/8" TRUSTED_PROXIES: "cloud.teier.eu 138.201.74.231 172.0.0.1/8"
APACHE_DISABLE_REWRITE_IP: "1" APACHE_DISABLE_REWRITE_IP: "1"
OVERWRITEHOST: "cloud.teier.eu" OVERWRITEHOST: "cloud.teier.eu"
@ -14,7 +14,7 @@ services:
OVERWRITEWEBROOT: "/" OVERWRITEWEBROOT: "/"
OVERWRITECONADDR: "138.201.74.231" OVERWRITECONADDR: "138.201.74.231"
networks: networks:
- "mariadb_net" - "postgres_net"
- "nextcloud_net" - "nextcloud_net"
volumes: volumes:
- /var/nextcloud:/var/www/html - /var/nextcloud:/var/www/html
@ -34,6 +34,5 @@ networks:
name: "nextcloud_net" name: "nextcloud_net"
driver: bridge driver: bridge
mariadb_net: mariadb_net:
name: "mariadb_net" name: "postgres_net"
external: true external: true

View File

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

View File

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

View File

@ -2,26 +2,23 @@
- hosts: teier.eu - hosts: teier.eu
gather_facts: no gather_facts: no
tasks: tasks:
- name: Install PyMySQL
shell: pip install PyMySQL
- name: Create database for Nummus - name: Create database for Nummus
community.mysql.mysql_db: community.postgresql.postgresql_db
login_user: root login_user: root
login_password: "{{ lookup('env', 'MARIADB_ROOT_PASSWORD') }}" login_password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
name: nummus name: nummus
state: present state: present
- name: Create database user for Nummus - name: Create database user for Nummus
community.mysql.mysql_user: community.postgresql.postgresql_user:
login_user: root login_user: postgres
login_password: "{{ lookup('env', 'MARIADB_ROOT_PASSWORD') }}" login_password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
host: "%"
name: "nummus" name: "nummus"
db: nummus
password: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}" password: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}"
priv: 'nummus.*:ALL' priv: 'ALL'
state: present state: present
- name: Check dc directory - name: Check dc directory
stat: stat:
path: /dc/nummus path: /dc/nummus
@ -44,4 +41,4 @@
- name: Start nummus - name: Start nummus
shell: "cd /dc/nummus && docker-compose up -d" shell: "cd /dc/nummus && docker-compose up -d"
environment: environment:
NUMMUS_DB_PASSWORD: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}" NUMMUS_DB_PASSWORD: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}"

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