PostgreSQL
Deploy PostgreSQL database server.
Ansible hosts group: postgres
Variables
| Option | Type | Description | Default |
|---|---|---|---|
cs_postgres_cluster_name | string | Instance isolation | {{ cs_cluster_name }} |
cs_postgres_container_name | string | Postgres container name | postgres |
cs_postgres_network_name | string | Postgres network name | postgres |
cs_postgres_docker_tag | string | Postgres docker tag | 18.6-trixie |
cs_postgres_docker_image | string | Postgres docker image | {{ cs_vm_artifact_registry_containers_home }}/postgres |
cs_postgres_dir | string | Postgres data directory | /app/postgres/main/18 |
cs_postgres_run_user | string | Postgres run user ID | 999 |
cs_postgres_run_group | string | Postgres run group ID | 999 |
cs_postgres_maintenance_db | string | Postgres maintenance database | postgres |
cs_postgres_maintenance_user | string | Postgres maintenance user | postgres |
Vault configurations
- key:
{{ cs_project_code }}/application-deployer/clusters/{{ Lab Name or Cluster name }}/hosts/{{ hostname }}/apps/postgresql/config
{
"port": "(int) db port",
"apps_dict": {
"<DB Name>": {
"password": "DB Password",
"user": "DB login username"
}
},
"maintenance_password": "Root password"
}
Container data directory
The container's PGDATA is pinned to /var/lib/postgresql/data, which is bind-mounted from
{{ cs_postgres_dir }}/data on the host. The override is required because, from major version 18 on, the official
PostgreSQL image's default PGDATA is a different path.
Tags
postgres: Deploy postgres server.
Deployment
uv sync --all-extras --all-packages --no-progress
uv --offline run --no-sync --no-progress ansible-galaxy install -r requirements.yml
uv --offline run --no-sync --no-progress ansible-playbook playbook.yml --tags postgres