mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-12-01 16:54:35 +01:00
1.5 KiB
1.5 KiB
Docker-Postgres Ansible Role
Overview
This Ansible role is designed to deploy a PostgreSQL database using Docker. It includes tasks for setting up a Docker network, installing PostgreSQL in a Docker container, and initializing the database with a specified user and database.
Role Variables
central_postgres_password
: The password for the PostgreSQL superuser (postgres
).database_databasename
: Name of the database to be created.database_username
: Username for the database user.database_password
: Password for the database user.
Role Tasks
- Create Docker network for PostgreSQL: Sets up a Docker network for PostgreSQL communication.
- Install PostgreSQL: Deploys PostgreSQL in a Docker container, attaching it to the created network and setting the superuser password.
- Run the docker_postgres tasks once: Ensures that the tasks are only run once to avoid redundancy.
Handlers
- Create database: Creates a new database with the specified name.
- Create database user: Sets up a user with full privileges on the newly created database.
Usage
- Set the required variables in your playbook or inventory file.
- Include this role in your playbook.
- Run the playbook against the target host.
Notes
- The PostgreSQL server is bound to
127.0.0.1:5432
on the host machine, making it accessible only from localhost. - Ensure that the provided passwords are secure and stored securely, preferably using Ansible Vault or another encryption method.