mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-21 20:31:02 +01:00
Compare commits
No commits in common. "3581db27aa49f76a9256c093e0a0092fcea5e288" and "2831999dfc15380d6e861a74cae121b537a30d12" have entirely different histories.
3581db27aa
...
2831999dfc
@ -1,27 +0,0 @@
|
||||
# MariaDB Docker Ansible Role
|
||||
|
||||
## Overview
|
||||
This Ansible role facilitates the deployment of a MariaDB server using Docker. It is designed to ensure ease of installation and configuration, with the flexibility to adapt to different environments.
|
||||
|
||||
## Features
|
||||
- **Dockerized MariaDB**: Leverages Docker for MariaDB deployment, ensuring consistency across different environments.
|
||||
- **Customizable Settings**: Allows customization of the MariaDB instance through various Ansible variables.
|
||||
- **Network Configuration**: Includes setup of a dedicated Docker network for MariaDB.
|
||||
- **Idempotent Design**: Ensures that repeat runs of the playbook do not result in unwanted changes.
|
||||
- **Security Focused**: Implements best practices for securing the MariaDB root password.
|
||||
|
||||
## Prerequisites
|
||||
Before using this role, ensure you have the following:
|
||||
- Ansible installed on the control machine.
|
||||
- Docker installed on the target host(s).
|
||||
- Access to the target host(s) via SSH.
|
||||
|
||||
## Configuration
|
||||
Configure the role by setting the required variables. These can be set in the playbook or in a separate variable file:
|
||||
- `central_mariadb_root_password`: The root password for the MariaDB server.
|
||||
- `database_databasename`: The name of the initial database to create.
|
||||
- `database_username`: The username for the database user.
|
||||
- `database_password`: The password for the database user.
|
||||
|
||||
## Contributing
|
||||
Contributions to this project are welcome. Please submit issues and pull requests with your suggestions.
|
@ -1,21 +0,0 @@
|
||||
- name: create database
|
||||
mysql_db:
|
||||
name: "{{database_databasename}}"
|
||||
state: present
|
||||
login_user: root
|
||||
login_password: "{{central_mariadb_root_password}}"
|
||||
login_host: 127.0.0.1
|
||||
login_port: 3306
|
||||
listen: create database
|
||||
|
||||
- name: create database user
|
||||
mysql_user:
|
||||
name: "{{database_username}}"
|
||||
password: "{{database_password}}"
|
||||
priv: '{{database_databasename}}.*:ALL'
|
||||
state: present
|
||||
login_user: root
|
||||
login_password: "{{central_mariadb_root_password}}"
|
||||
login_host: 127.0.0.1
|
||||
login_port: 3306
|
||||
listen: create database
|
@ -1,23 +0,0 @@
|
||||
- name: Create Docker network for MariaDB
|
||||
docker_network:
|
||||
name: mariadb_network
|
||||
state: present
|
||||
when: run_once_docker_mariadb is not defined
|
||||
|
||||
- name: install MariaDB
|
||||
docker_container:
|
||||
name: mariadb
|
||||
image: mariadb:latest
|
||||
detach: yes
|
||||
env:
|
||||
MARIADB_ROOT_PASSWORD: "{{central_mariadb_root_password}}"
|
||||
networks:
|
||||
- name: mariadb_network
|
||||
published_ports:
|
||||
- "127.0.0.1:3306:3306"
|
||||
when: run_once_docker_mariadb is not defined
|
||||
|
||||
- name: run the docker_mariadb tasks once
|
||||
set_fact:
|
||||
run_once_docker_mariadb: true
|
||||
when: run_once_docker_mariadb is not defined
|
@ -1,28 +0,0 @@
|
||||
# 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
|
||||
1. **Create Docker network for PostgreSQL**: Sets up a Docker network for PostgreSQL communication.
|
||||
2. **Install PostgreSQL**: Deploys PostgreSQL in a Docker container, attaching it to the created network and setting the superuser password.
|
||||
3. **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
|
||||
1. Set the required variables in your playbook or inventory file.
|
||||
2. Include this role in your playbook.
|
||||
3. 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.
|
@ -1,22 +0,0 @@
|
||||
- name: Create database
|
||||
postgresql_db:
|
||||
name: "{{ database_databasename }}"
|
||||
state: present
|
||||
login_user: postgres
|
||||
login_password: "{{ central_postgres_password }}"
|
||||
login_host: 127.0.0.1
|
||||
login_port: 5432
|
||||
listen: create database
|
||||
|
||||
- name: Create database user
|
||||
postgresql_user:
|
||||
name: "{{ database_username }}"
|
||||
password: "{{ database_password }}"
|
||||
db: "{{ database_databasename }}"
|
||||
priv: ALL
|
||||
state: present
|
||||
login_user: postgres
|
||||
login_password: "{{ central_postgres_password }}"
|
||||
login_host: 127.0.0.1
|
||||
login_port: 5432
|
||||
listen: create database
|
@ -1,23 +0,0 @@
|
||||
- name: Create Docker network for PostgreSQL
|
||||
docker_network:
|
||||
name: postgres_network
|
||||
state: present
|
||||
when: run_once_docker_postgres is not defined
|
||||
|
||||
- name: Install PostgreSQL
|
||||
docker_container:
|
||||
name: postgres
|
||||
image: postgres:latest
|
||||
detach: yes
|
||||
env:
|
||||
POSTGRES_PASSWORD: "{{ central_postgres_password }}"
|
||||
networks:
|
||||
- name: postgres_network
|
||||
published_ports:
|
||||
- "127.0.0.1:5432:5432"
|
||||
when: run_once_docker_postgres is not defined
|
||||
|
||||
- name: Run the docker_postgres tasks once
|
||||
set_fact:
|
||||
run_once_docker_postgres: true
|
||||
when: run_once_docker_postgres is not defined
|
Loading…
Reference in New Issue
Block a user