Remote volumes for pg and pgadmin

This commit is contained in:
Andrea Dell'Amico 2023-06-03 14:23:39 +02:00
parent 81ab45f289
commit cc4eff77e8
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 35 additions and 1 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"ansible.python.interpreterPath": "/opt/local/bin/python3.10"
}

View File

@ -19,11 +19,17 @@ open_asfa_db_port: 5432
open_asfa_db_name: 'asfadb' open_asfa_db_name: 'asfadb'
open_asfa_db_user: 'asfadb_user' open_asfa_db_user: 'asfadb_user'
open_asfa_db_volume: 'asfa_pg_data' open_asfa_db_volume: 'asfa_pg_data'
open_asfa_pg_volume_type: 'local'
open_asfa_pg_volume_o: ""
open_asfa_pg_volume_device: ""
open_asfa_db_allowed_hosts: open_asfa_db_allowed_hosts:
- '127.0.0.1/8' - '127.0.0.1/8'
open_asfa_db_constraints: '[node.labels.pg_data_asfa_test==asfa_server_test]' open_asfa_db_constraints: '[node.labels.pg_data_asfa_test==asfa_server_test]'
open_asfa_pgadmin_image: 'dpage/pgadmin4' open_asfa_pgadmin_image: 'dpage/pgadmin4'
open_asfa_pgadmin_data_vol: 'asfa_test_pgadmin_data' open_asfa_pgadmin_data_vol: 'asfa_test_pgadmin_data'
open_asfa_pgadmin_volume_type: 'local'
open_asfa_pgadmin_volume_o: ""
open_asfa_pgadmin_volume_device: ""
open_asfa_pgadmin_docker_host: '{{ open_asfa_db_docker_host }}' open_asfa_pgadmin_docker_host: '{{ open_asfa_db_docker_host }}'
open_asfa_pgadmin_constraints: '[node.labels.pgadmin_data_asfa_test==asfa_server_test]' open_asfa_pgadmin_constraints: '[node.labels.pgadmin_data_asfa_test==asfa_server_test]'
open_asfa_pgadmin_email: 'noreply@example.com' open_asfa_pgadmin_email: 'noreply@example.com'

View File

@ -8,8 +8,25 @@ networks:
{{ open_asfa_docker_network }}: {{ open_asfa_docker_network }}:
volumes: volumes:
{{ open_asfa_db_volume }}:
{{ open_asfa_pgadmin_data_vol }}: {{ open_asfa_pgadmin_data_vol }}:
{% if open_asfa_pgadmin_volume_type == "nfs4" %}
driver: local
driver_opts:
type: {{ open_asfa_pgadmin_volume_type }}
o: "{{ open_asfa_pgadmin_volume_o }}"
device: "{{ open_asfa_pgadmin_volume_device }}"
{% endif %}
{{ open_asfa_db_volume }}:
{% if open_asfa_pg_volume_type == "nfs4" %}
driver: local
driver_opts:
type: {{ open_asfa_pg_volume_type }}
o: "{{ open_asfa_pg_volume_o }}"
device: "{{ open_asfa_pg_volume_device }}"
{% endif %}
services: services:
pg: pg:
@ -27,7 +44,11 @@ services:
PGDATA: /var/lib/postgresql/data/pg_data PGDATA: /var/lib/postgresql/data/pg_data
deploy: deploy:
placement: placement:
{% if open_asfa_pg_volume_type == "nfs4" %}
constraints: [node.role == worker]
{% else %}
constraints: {{ open_asfa_db_constraints }} constraints: {{ open_asfa_db_constraints }}
{% endif %}
restart_policy: restart_policy:
condition: on-failure condition: on-failure
delay: 5s delay: 5s
@ -56,7 +77,11 @@ services:
GUNICORN_THREADS: 20 GUNICORN_THREADS: 20
deploy: deploy:
placement: placement:
{% if open_asfa_pgadmin_volume_type == "nfs4" %}
constraints: [node.role == worker]
{% else %}
constraints: {{ open_asfa_pgadmin_constraints }} constraints: {{ open_asfa_pgadmin_constraints }}
{% endif %}
restart_policy: restart_policy:
condition: on-failure condition: on-failure
delay: 5s delay: 5s