Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devture/com.devture.ansible.role.postgres
An Ansible role which installs Postgres to run as a Docker container wrapped in a systemd service
https://github.com/devture/com.devture.ansible.role.postgres
ansible-role docker postgres
Last synced: 3 months ago
JSON representation
An Ansible role which installs Postgres to run as a Docker container wrapped in a systemd service
- Host: GitHub
- URL: https://github.com/devture/com.devture.ansible.role.postgres
- Owner: devture
- License: agpl-3.0
- Created: 2022-10-21T08:16:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-04T08:37:06.000Z (8 months ago)
- Last Synced: 2024-06-04T09:56:07.688Z (8 months ago)
- Topics: ansible-role, docker, postgres
- Language: Jinja
- Homepage:
- Size: 75.2 KB
- Stars: 3
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Postgres Ansible role
⚠️ **WARNING**: this role is now maintained in [mother-of-all-self-hosting/ansible-role-postgres](https://github.com/mother-of-all-self-hosting/ansible-role-postgres).
This is an [Ansible](https://www.ansible.com/) role which installs [Postgres](https://www.postgresql.org/) to run as a [Docker](https://www.docker.com/) container wrapped in a systemd service.
This role *implicitly* depends on:
- [`com.devture.ansible.role.playbook_help`](https://github.com/devture/com.devture.ansible.role.playbook_help)
- [`com.devture.ansible.role.systemd_docker_base`](https://github.com/devture/com.devture.ansible.role.systemd_docker_base)## Features
- **multiple databases support**: this role manages one main database and root credentials, and optionally a list of additional managed databases with their own credentials (see `devture_postgres_managed_databases`)
- **backward compatible**: even if a new Postgres version is available, the role will keep you on the Postgres version you had started with until you perform a major upgrade manually (see below)
- **upgrading between major Postgres versions**: invoking the playbook with a `--tags=upgrade-postgres` performs a dump, data move (`data` -> `data-auto-upgrade-backup`), rebuild, and dump import
- **importing existing Postgres database dumps**: you can import plain-text (`.sql`) or gzipped (`sql.gz`) dumps with the `--tags=import-postgres` tag
- **import data from SQLite, NeDB, etc**: this is an internal task (not exposed as a playbook tag), but the role supports using [pgloader](https://pgloader.io/) to load data into Postgres
- **vacuum support**: you can vacuum the database using the `--tags=run-postgres-vacuum` tag
- **helpful scripts**:
- get a `psql` interactive terminal via the `/base_path/bin/cli` and `/base_path/bin/cli-non-interactive` scripts
- dump all databases using the `/base_path/bin/dump-all DIRECTORY_PATH` (which will dump to a `latest-dump.sql.gz` file there)## Usage
Example playbook:
```yaml
- hosts: servers
roles:
- role: galaxy/com.devture.ansible.role.systemd_docker_base- role: galaxy/com.devture.ansible.role.postgres
- role: another_role
```Example playbook configuration (`group_vars/servers` or other):
```yaml
devture_postgres_identifier: my-postgresdevture_postgres_base_path: "{{ my_base_path }}/postgres"
devture_postgres_container_network: "{{ my_container_container_network }}"
devture_postgres_uid: "{{ my_uid }}"
devture_postgres_gid: "{{ my_gid }}"devture_postgres_vacuum_default_databases_list: ["mydb", "anotherdb"]
devture_postgres_systemd_services_to_stop_for_maintenance_list: |
{{
(['my-service.service'])
}}devture_postgres_managed_databases: |
{{
[{
'name': my_database_name,
'username': my_database_username,
'password': my_database_password,
}]
+
[{
'name': another_database_name,
'username': another_database_username,
'password': another_database_password,
}]
}}
```