PostgreSQL (Host Install)¶
Overview¶
PostgreSQL (Host Install) is an object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance.
This role supports multiple PostgreSQL versions running simultaneously, each on different ports, with full user and database management capabilities.
Advanced Users Only
This role is intended for advanced users who are comfortable running a database server directly on the host system and are aware of the security implications and maintenance considerations involved. Most users should use the PostgreSQL Docker container instead.
Deployment¶
sb install postgres-host
Usage¶
PostgreSQL is installed directly on the host with data stored in /opt/postgresql/. The default version is 17 (port 5432), with multiple versions supported via postgres_host_role_versions in your Saltbox inventory. Each version runs on sequential ports (5432, 5433, etc.) as separate systemd services.
Configure per-version users, databases, and access control using postgres_host_role_config in your inventory. Default root superuser is root/password4321 (change this!). Connect from Docker using host.docker.internal:5432.
Role Defaults¶
Use the Inventory to customize variables. (1)
-
Example override
postgres_host_role_versions: ["item1", "item2"]
postgres_host_role_versions
# Supports any versions from https://wiki.postgresql.org/wiki/Apt
# Each version is unique and you cannot specify the same version twice
# Type: list
postgres_host_role_versions: ["17"]
postgres_host_role_create_root_superuser
# Type: bool (true/false)
postgres_host_role_create_root_superuser: true
postgres_host_role_root_superuser_name
# Type: string
postgres_host_role_root_superuser_name: "root"
postgres_host_role_root_superuser_password
# Type: string
postgres_host_role_root_superuser_password: "password4321"
postgres_host_role_config
# Example:
# postgres_host_role_config:
# "16":
# allowed_hosts:
# - "172.19.0.0/16"
# - "10.0.0.0/8"
# auth_method: "md5"
# users:
# - name: "app_user"
# password: "password1"
# - name: "app_user2"
# password: "password2"
# databases:
# - name: "app_database"
# users:
# - "app_user"
# - "app_user2"
# - name: "metrics_db"
# users:
# - "app_user"
# "17":
# allowed_hosts:
# - "172.19.0.0/16"
# auth_method: "scram-sha-256"
# users:
# - name: "app_user3"
# password: "password3"
# databases:
# - name: "new_app_database"
# users:
# - "app_user3"
# Type: dict
postgres_host_role_config: {}
postgres_host_role_allowed_hosts
# Type: list
postgres_host_role_allowed_hosts:
- "172.19.0.0/16"
postgres_host_role_auth_method
# Type: string
postgres_host_role_auth_method: "scram-sha-256"
postgres_host_role_users
# Type: list
postgres_host_role_users:
- name: "{{ user.name }}"
password: "{{ user.pass }}"
postgres_host_role_databases
# Type: list
postgres_host_role_databases:
- name: "saltbox"
users: ["{{ user.name }}"]