drop mongodb-old role

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-07-31 15:11:18 -04:00
parent fc80d31908
commit a897485c07
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
7 changed files with 0 additions and 130 deletions

View File

@ -1,24 +0,0 @@
# Description
This role configures a [MongoDB](https://www.mongodb.com/) container using the [`mongo`](ttps://hub.docker.com/_/mongo) Docker image.
# Configuration
```yaml
mongo_db_name: mydb
mongo_db_user: test
mongo_db_pass: test-user-password
```
# Backups
Setup of backups created via the [`mongodump`](https://docs.mongodb.com/manual/reference/program/mongodump/#bin.mongodump) utility.
The backups end up in:
```yaml
mongo_backup_path: '/var/tmp/backups'
```
# Known Issues
__TODO__

View File

@ -1,22 +0,0 @@
---
mongo_cont_name: mongodb
# https://hub.docker.com/_/mongo
mongo_cont_tag: '4.1.13-bionic'
mongo_cont_image: 'mongo:{{ mongo_cont_tag }}'
mongo_cont_vol: '/docker/{{ mongo_cont_name }}'
mongo_cont_uid: 999
mongo_host_uid: '{{ 100000 + mongo_cont_uid - 1 | int }}'
mongo_cont_port: 27017
mongo_db_name: ~
mongo_db_user: ~
mongo_db_pass: ~
# path for mongodump backups
mongo_backup_path: '/var/tmp/backups'
mongo_backup_script: '/var/lib/backups/{{ mongo_cont_name | replace("-", "_") }}_dump.sh'
# general container config
cont_state: started
cont_recreate: false
cont_restart: false

View File

@ -1,3 +0,0 @@
---
- name: Save iptables rules
shell: iptables-save > /etc/iptables/rules.v4

View File

@ -1,37 +0,0 @@
---
- name: MongoDB | Create directores for backups
file:
path: '{{ item }}'
state: directory
group: adm
mode: 0775
with_items:
- '/var/lib/backups'
- '{{ mongo_backup_path }}'
- name: MongoDB | Create dump script
copy:
dest: '/var/lib/backups/mongodb_dump.sh'
content: |
#!/usr/bin/env bash
TSTAMP=$(date -u +%Y%m%d%H%M%S)
BKP_DIR={{ mongo_backup_path }}
/usr/bin/docker exec \
-i {{ mongo_cont_name }} mongodump \
--verbose \
--host=localhost \
--port={{ mongo_cont_port }} \
--db={{ mongo_db_name }} \
--username={{ mongo_db_user }} \
--password={{ mongo_db_pass }} \
--authenticationDatabase=admin \
--out=${BKP_DIR}/{{ mongo_cont_name | replace("-", "_") }}_dump_${TSTAMP}.bson
group: adm
mode: 0750
- name: MongoDB | Configure dump cron job
cron:
name: MongoDB Dump
special_time: daily
user: root
job: '{{ mongo_backup_script }}'

View File

@ -1,28 +0,0 @@
---
- name: Create data directory
file:
path: '{{ mongo_cont_vol }}/data'
state: directory
owner: '{{ mongo_host_uid }}'
group: docker
recurse: true
- name: Start the MongoDB container
docker_container:
name: '{{ mongo_cont_name }}'
image: '{{ mongo_cont_image }}'
pull: true
restart_policy: always
state: '{{ cont_state }}'
recreate: '{{ cont_recreate }}'
restart: '{{ cont_restart }}'
env:
MONGO_INITDB_ROOT_USERNAME: '{{ mongo_db_user | mandatory }}'
MONGO_INITDB_ROOT_PASSWORD: '{{ mongo_db_pass | mandatory }}'
# This var doesn't do what you think it does!
# https://github.com/docker-library/mongo/issues/329
MONGO_INITDB_DATABASE: '{{ mongo_db_name | mandatory }}'
ports:
- '0.0.0.0:{{ mongo_cont_port }}:{{ mongo_cont_port }}/tcp'
volumes:
- '{{ mongo_cont_vol }}/data:/data/db'

View File

@ -1,12 +0,0 @@
---
- name: Enable MongoDB port
iptables:
comment: '{{ mongo_cont_name }}'
action: insert
chain: DOCKER-USER
jump: ACCEPT
source: '0.0.0.0/0'
protocol: 'tcp'
destination_port: '{{ mongo_cont_port }}'
notify:
- Save iptables rules

View File

@ -1,4 +0,0 @@
---
- import_tasks: container.yml
- import_tasks: backup.yml
- import_tasks: firewall.yml