74 lines
No EOL
2 KiB
YAML
74 lines
No EOL
2 KiB
YAML
---
|
|
- name: Deploy PostgreSQL server on CM3588 with RAID0
|
|
hosts: postgres
|
|
become: yes
|
|
gather_facts: yes
|
|
|
|
pre_tasks:
|
|
- name: Set hostname
|
|
hostname:
|
|
name: postgres
|
|
|
|
- name: Update /etc/hosts
|
|
lineinfile:
|
|
path: /etc/hosts
|
|
regexp: '^127\.0\.1\.1'
|
|
line: '127.0.1.1 postgres'
|
|
state: present
|
|
|
|
- name: Update apt cache
|
|
apt:
|
|
update_cache: yes
|
|
cache_valid_time: 3600
|
|
|
|
- name: Install Python dependencies for Ansible
|
|
apt:
|
|
name:
|
|
- python3-apt
|
|
- python3-psycopg2
|
|
state: present
|
|
|
|
roles:
|
|
- raid
|
|
- postgresql
|
|
|
|
post_tasks:
|
|
- name: Display PostgreSQL connection information
|
|
debug:
|
|
msg: |
|
|
PostgreSQL has been configured on {{ inventory_hostname }}
|
|
|
|
Connection details:
|
|
- Host: {{ ansible_host }}
|
|
- Port: 5432 (PostgreSQL direct)
|
|
- Port: 6432 (PgBouncer pooled)
|
|
- Database: aprsme_prod
|
|
- User: aprsme
|
|
|
|
RAID0 array status:
|
|
- Device: /dev/md0
|
|
- Mount: /var/lib/postgresql
|
|
- Size: ~4TB (2x2TB in RAID0)
|
|
|
|
To connect from your k3s cluster:
|
|
psql -h {{ ansible_host }} -p 6432 -U aprsme -d aprsme_prod
|
|
|
|
Remember to:
|
|
1. Update your APRS.me DATABASE_URL to point to this server
|
|
2. Run migrations: mix ecto.migrate
|
|
3. Monitor disk usage and performance
|
|
4. Set up regular backups to external storage
|
|
|
|
- name: Test PostgreSQL connection
|
|
postgresql_ping:
|
|
db: aprsme_prod
|
|
login_host: localhost
|
|
login_port: 5432
|
|
login_user: aprsme
|
|
login_password: "{{ vault_postgresql_aprsme_password }}"
|
|
register: db_ping
|
|
ignore_errors: yes
|
|
|
|
- name: Show connection test result
|
|
debug:
|
|
msg: "Database connection test: {{ 'SUCCESS' if db_ping is succeeded else 'FAILED' }}" |