diff --git a/init-nextcloud.sh b/init-nextcloud.sh index d68779c..c809e1f 100644 --- a/init-nextcloud.sh +++ b/init-nextcloud.sh @@ -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 \ No newline at end of file +ansible-playbook nextcloud/init.yml diff --git a/mautrix-signal/docker-compose.yml b/mautrix-signal/docker-compose.yml new file mode 100644 index 0000000..c2534c8 --- /dev/null +++ b/mautrix-signal/docker-compose.yml @@ -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 diff --git a/mautrix-signal/start.yml b/mautrix-signal/start.yml new file mode 100644 index 0000000..baf7606 --- /dev/null +++ b/mautrix-signal/start.yml @@ -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" diff --git a/mautrix-signal/stop.yml b/mautrix-signal/stop.yml new file mode 100644 index 0000000..a83188b --- /dev/null +++ b/mautrix-signal/stop.yml @@ -0,0 +1,6 @@ +--- +- hosts: teier.eu + gather_facts: no + tasks: + - name: Stop Mariadb + shell: "cd /dc/mariadb && docker-compose stop" \ No newline at end of file diff --git a/mautrix-signal/teardown.yml b/mautrix-signal/teardown.yml new file mode 100644 index 0000000..d05493f --- /dev/null +++ b/mautrix-signal/teardown.yml @@ -0,0 +1,6 @@ +--- +- hosts: teier.eu + gather_facts: no + tasks: + - name: Teardown mariadb + shell: "cd /dc/mariadb && docker-compose down" \ No newline at end of file diff --git a/nextcloud/docker-compose.yml b/nextcloud/docker-compose.yml index b1ed737..bb48bf9 100644 --- a/nextcloud/docker-compose.yml +++ b/nextcloud/docker-compose.yml @@ -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 - \ No newline at end of file diff --git a/nextcloud/init.yml b/nextcloud/init.yml index e0681f8..3847a1c 100644 --- a/nextcloud/init.yml +++ b/nextcloud/init.yml @@ -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 @@ -49,4 +46,4 @@ - name: Start nextcloud shell: "cd /dc/nextcloud && docker-compose up -d" environment: - NEXTCLOUD_DB_PASSWORD: "{{ lookup('env', 'NEXTCLOUD_DB_PASSWORD') }}" \ No newline at end of file + NEXTCLOUD_DB_PASSWORD: "{{ lookup('env', 'NEXTCLOUD_DB_PASSWORD') }}" diff --git a/nummus/docker-compose.yml b/nummus/docker-compose.yml index 078217d..ccfa630 100644 --- a/nummus/docker-compose.yml +++ b/nummus/docker-compose.yml @@ -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 - \ No newline at end of file diff --git a/nummus/init.yml b/nummus/init.yml index ae7001e..9a84624 100644 --- a/nummus/init.yml +++ b/nummus/init.yml @@ -2,26 +2,23 @@ - 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 stat: path: /dc/nummus @@ -44,4 +41,4 @@ - name: Start nummus shell: "cd /dc/nummus && docker-compose up -d" environment: - NUMMUS_DB_PASSWORD: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}" \ No newline at end of file + NUMMUS_DB_PASSWORD: "{{ lookup('env', 'NUMMUS_DB_PASSWORD') }}" diff --git a/postgres/docker-compose.yml b/postgres/docker-compose.yml new file mode 100644 index 0000000..1506ccd --- /dev/null +++ b/postgres/docker-compose.yml @@ -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 diff --git a/postgres/start.yml b/postgres/start.yml new file mode 100644 index 0000000..47be434 --- /dev/null +++ b/postgres/start.yml @@ -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') }}" diff --git a/postgres/stop.yml b/postgres/stop.yml new file mode 100644 index 0000000..de4ed30 --- /dev/null +++ b/postgres/stop.yml @@ -0,0 +1,6 @@ +--- +- hosts: teier.eu + gather_facts: no + tasks: + - name: Stop Postgres + shell: "cd /dc/postgres && docker-compose stop" diff --git a/postgres/teardown.yml b/postgres/teardown.yml new file mode 100644 index 0000000..a87cd2d --- /dev/null +++ b/postgres/teardown.yml @@ -0,0 +1,6 @@ +--- +- hosts: teier.eu + gather_facts: no + tasks: + - name: Teardown Postgres + shell: "cd /dc/postgres && docker-compose down" diff --git a/start-postgres.sh b/start-postgres.sh new file mode 100644 index 0000000..e2c3f14 --- /dev/null +++ b/start-postgres.sh @@ -0,0 +1,5 @@ +#!/bin/bash +source ./.env + +[ -z "$POSTGRES_PASSWORD" ] && echo "POSTGRES_PASSWORD not set" && exit 1 +ansible-playbook postgres/start.yml