This commit is contained in:
36
ansible/plays/templates/macro/postgres.j2
Normal file
36
ansible/plays/templates/macro/postgres.j2
Normal file
@ -0,0 +1,36 @@
|
||||
{# https://github.com/prodrigestivill/docker-postgres-backup-local #}
|
||||
{% macro postgres(name, user, pass, db, networks, schedule="@daily", version="15") %}
|
||||
{{ name | mandatory | string }}:
|
||||
image: postgres:{{ version | mandatory }}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_USER={{ user | mandatory }}
|
||||
- POSTGRES_DB={{ db | mandatory }}
|
||||
- POSTGRES_PASSWORD={{ pass | mandatory }}
|
||||
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
|
||||
networks: {{ networks | mandatory | list | union(["postgres"]) | sort }}
|
||||
volumes:
|
||||
- {{ name | string | lower }}_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready", "-U", "{{ user }}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
{{ name | mandatory | string }}_pgbackup:
|
||||
image: prodrigestivill/postgres-backup-local:latest
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- "/opt/pgbackups/${COMPOSE_PROJECT_NAME}/:/backups:z"
|
||||
networks:
|
||||
- postgres
|
||||
depends_on:
|
||||
- {{ name | mandatory | string }}
|
||||
environment:
|
||||
- POSTGRES_HOST={{ name | mandatory | string }}
|
||||
- POSTGRES_USER={{ user | mandatory }}
|
||||
- POSTGRES_DB={{ db | mandatory }}
|
||||
- POSTGRES_PASSWORD={{ pass | mandatory }}
|
||||
- POSTGRES_EXTRA_OPTS=-Z6 --schema=public --blobs
|
||||
- SCHEDULE={{ schedule | mandatory }}
|
||||
{% endmacro %}
|
||||
|
Reference in New Issue
Block a user