Skip to main content

PostgreSQL

Deploy PostgreSQL database server.

Ansible hosts group: postgres​

Variables​

OptionTypeDescriptionDefault
cs_postgres_cluster_namestringInstance isolation{{ cs_cluster_name }}
cs_postgres_container_namestringPostgres container namepostgres
cs_postgres_network_namestringPostgres network namepostgres
cs_postgres_docker_tagstringPostgres docker tag18.6-trixie
cs_postgres_docker_imagestringPostgres docker image{{ cs_vm_artifact_registry_containers_home }}/postgres
cs_postgres_dirstringPostgres data directory/app/postgres/main/18
cs_postgres_run_userstringPostgres run user ID999
cs_postgres_run_groupstringPostgres run group ID999
cs_postgres_maintenance_dbstringPostgres maintenance databasepostgres
cs_postgres_maintenance_userstringPostgres maintenance userpostgres

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