devxy/ansible-database
Watch
0
0
Fork
You've already forked ansible-database
0
  • Jinja 92.3%
  • Just 7.4%
  • JavaScript 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-30 08:39:42 +00:00
.crow chore(deps): update codeberg.org/crow-plugins/clone docker tag to v1.2.3 (#85) 2026-11-17 02:49:06 +00:00
.gitsv init 2025-12-27 22:29:16 +01:00
ansibledoctor/templates/readme init 2025-12-27 22:29:16 +01:00
meta init 2025-12-27 22:29:16 +01:00
roles chore(deps): update pgautoupgrade/pgautoupgrade docker tag to v19 (#93) 2026-11-30 08:38:23 +00:00
.ansible-lint feat(postgres_exporter): add Prometheus postgres_exporter role (#5) 2026-03-21 14:09:30 +00:00
.ansibledoctor.yaml init 2025-12-27 22:29:16 +01:00
.editorconfig init 2025-12-27 22:29:16 +01:00
.editorconfig-checker.json init 2025-12-27 22:29:16 +01:00
.gitignore feat(pgdog): add pgdog role as drop-in sibling of pgbouncer (#16) 2026-06-08 19:14:45 +00:00
.markdownlint-cli2.yaml init 2025-12-27 22:29:16 +01:00
.markdownlint.yaml init 2025-12-27 22:29:16 +01:00
.pre-commit-config.yaml chore(pre-commit): use prek builtin hooks (#92) 2026-11-27 10:27:45 +00:00
.yamllint.yaml init 2025-12-27 22:29:16 +01:00
commitlint.config.mjs init 2025-12-27 22:29:16 +01:00
galaxy.yml [skip ci] Update galaxy.yml after release 2026-11-30 08:39:42 +00:00
Justfile fix: strip ansible-doctor generator artifact from README 2025-12-28 11:02:09 +01:00
README.md feat(pgdog): add pgdog role as drop-in sibling of pgbouncer (#16) 2026-06-08 19:14:45 +00:00
renovate.json init 2025-12-27 22:29:16 +01:00

Ansible Collection "database"

status-badge

Ansible collection for deploying and managing PostgreSQL database infrastructure.

Roles

Role Description
postgres Deploy PostgreSQL with Docker using pgautoupgrade for automatic version upgrades
pgbouncer Deploy PgBouncer connection pooler with optimized defaults
pgdog Deploy PgDog connection pooler and query router (drop-in sibling of pgbouncer)
pgbackrest Install and configure pgBackRest for PostgreSQL backup management

Installation

ansible-galaxy collection install devxy.database

Usage

requirements.yml:

collections:
  - name: devxy.database
    version: ">=0.1.0"

Deploy PostgreSQL with Connection Pooling

- name: Deploy database infrastructure
  hosts: database_servers
  roles:
    # Deploy PostgreSQL
    - role: devxy.database.postgres
      postgres_password: "{{ vault_postgres_password }}"
      postgres_databases:
        - name: myapp
          owner: myapp_user
      postgres_users:
        - name: myapp_user
          password: "{{ vault_myapp_password }}"
          database: myapp
          privileges: ALL
      postgres_networks:
        - name: database_net

    # Deploy PgBouncer for connection pooling
    - role: devxy.database.pgbouncer
      pgbouncer_databases:
        - name: myapp
          host: postgres
          port: 5432
      pgbouncer_users:
        - name: myapp_user
          password: "{{ vault_myapp_password }}"
      pgbouncer_networks:
        - name: database_net

Deploy PostgreSQL with PgDog (read/write split)

PgDog is a drop-in alternative to PgBouncer. Swap the role name and the pgbouncer_* variable prefix for pgdog_*; PgDog listens on the same port (6432) and additionally load-balances reads across replicas.

- name: Deploy database infrastructure with PgDog
  hosts: database_servers
  roles:
    - role: devxy.database.postgres
      postgres_password: "{{ vault_postgres_password }}"
      postgres_networks:
        - name: database_net

    - role: devxy.database.pgdog
      pgdog_databases:
        - name: myapp
          host: postgres
          port: 5432
          role: primary
      pgdog_users:
        - name: myapp_user
          database: myapp
          password: "{{ vault_myapp_password }}"
      pgdog_networks:
        - name: database_net

Deploy PostgreSQL with Backup

- name: Deploy PostgreSQL with backup
  hosts: database_servers
  roles:
    - role: devxy.database.postgres
      postgres_password: "{{ vault_postgres_password }}"

    - role: devxy.database.pgbackrest
      pgbackrest_is_pg_host: true
      pgbackrest_stanza: main
      pgbackrest_repo_path: /var/lib/pgbackrest

Documentation

Refer to the README.md files within each individual role:

  • postgres - PostgreSQL deployment with auto-tuned settings
  • pgbouncer - Connection pooling with transaction mode
  • pgdog - Connection pooling and query routing with read/write split
  • pgbackrest - Backup and restore management

Ansible Galaxy

License

AGPL-3.0-or-later