infra/ansible/roles/postgresql/defaults/main.yml
2025-08-02 11:14:56 -05:00

122 lines
No EOL
3.4 KiB
YAML

---
# PostgreSQL version
postgresql_version: 17
# Password management
use_1password: false # Set to true to use 1Password for password storage
op_account_id: "YOOATCZZSVGH7AD6VABUVPORLI" # Default 1Password account ID
# Storage configuration
postgresql_storage_setup_enabled: false # Set to true to configure storage
postgresql_storage_type: raid0 # Options: single_nvme, raid0
postgresql_raid_device: /dev/md0
postgresql_storage_device: "{{ postgresql_raid_device if postgresql_storage_type == 'raid0' else '/dev/nvme0n1p1' }}"
postgresql_mount_point: /mnt/pgdata
# PostgreSQL configuration
postgresql_data_directory: /mnt/pgdata/{{ postgresql_version }}/main
postgresql_wal_directory: /mnt/pgdata/wal
postgresql_archive_directory: /mnt/pgdata/archive
postgresql_config_directory: /etc/postgresql/{{ postgresql_version }}/main
# Database settings for APRS.me
postgresql_databases:
- name: aprsme_prod
owner: aprsme
postgresql_users:
- name: aprsme
password: "{{ vault_postgresql_aprsme_password }}" # Store in vault
priv: "aprsme_prod:ALL"
# Performance tuning for CM3588 with 16GB RAM
# These are optimized for APRS.me workload
postgresql_config:
# Connection settings
listen_addresses: "'*'"
max_connections: 200 # Increased for 16GB system
# Memory settings (for 16GB RAM system)
shared_buffers: 4GB # 25% of RAM
effective_cache_size: 12GB # 75% of RAM
maintenance_work_mem: 1GB
work_mem: 64MB # Increased for available memory
# Disk settings optimized for RAID0 SSDs
random_page_cost: 1.1 # SSD optimization
effective_io_concurrency: 200 # Modern SSD
max_worker_processes: 4 # Pi 5 has 4 cores
max_parallel_workers_per_gather: 2
max_parallel_workers: 4
max_parallel_maintenance_workers: 2
# Write performance settings
wal_buffers: 32MB
checkpoint_completion_target: 0.9
checkpoint_timeout: 10min
max_wal_size: 4GB
min_wal_size: 512MB
# Logging
log_min_duration_statement: 1000 # Log queries over 1 second
log_checkpoints: on
log_connections: on
log_disconnections: on
log_line_prefix: "'%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '"
log_timezone: 'UTC'
# Query tuning
default_statistics_target: 100
# Autovacuum tuning for high insert rate
autovacuum: on
autovacuum_max_workers: 4
autovacuum_naptime: 30s # More frequent checks
autovacuum_vacuum_threshold: 50
autovacuum_analyze_threshold: 50
autovacuum_vacuum_scale_factor: 0.1 # 10% for more frequent vacuums
autovacuum_analyze_scale_factor: 0.05 # 5% for more frequent analyzes
# Enable query planning statistics
track_activity_query_size: 2048
track_io_timing: on
track_functions: all
# PostGIS specific
postgis.gdal_datapath: "'/usr/share/gdal'"
# Security settings
postgresql_hba_entries:
- type: local
database: all
user: postgres
auth_method: peer
- type: local
database: all
user: all
auth_method: peer
- type: host
database: all
user: all
address: 127.0.0.1/32
auth_method: scram-sha-256
- type: host
database: all
user: all
address: ::1/128
auth_method: scram-sha-256
- type: hostssl
database: aprsme_prod
user: aprsme
address: 10.0.0.0/8 # Adjust for your network
auth_method: scram-sha-256
# Backup settings
postgresql_backup_enabled: true
postgresql_backup_directory: /mnt/pgdata/backups
postgresql_backup_schedule:
minute: "0"
hour: "2"
day: "*"
month: "*"
weekday: "*"