From a897485c072f3535a1d4e27a9afc076fd26a70bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 31 Jul 2019 15:11:18 -0400 Subject: [PATCH] drop mongodb-old role MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ansible/roles/mongodb-old/README.md | 24 ------------ ansible/roles/mongodb-old/defaults/main.yml | 22 ----------- ansible/roles/mongodb-old/handlers/main.yml | 3 -- ansible/roles/mongodb-old/tasks/backup.yml | 37 ------------------- ansible/roles/mongodb-old/tasks/container.yml | 28 -------------- ansible/roles/mongodb-old/tasks/firewall.yml | 12 ------ ansible/roles/mongodb-old/tasks/main.yml | 4 -- 7 files changed, 130 deletions(-) delete mode 100644 ansible/roles/mongodb-old/README.md delete mode 100644 ansible/roles/mongodb-old/defaults/main.yml delete mode 100644 ansible/roles/mongodb-old/handlers/main.yml delete mode 100644 ansible/roles/mongodb-old/tasks/backup.yml delete mode 100644 ansible/roles/mongodb-old/tasks/container.yml delete mode 100644 ansible/roles/mongodb-old/tasks/firewall.yml delete mode 100644 ansible/roles/mongodb-old/tasks/main.yml diff --git a/ansible/roles/mongodb-old/README.md b/ansible/roles/mongodb-old/README.md deleted file mode 100644 index 66f8e81..0000000 --- a/ansible/roles/mongodb-old/README.md +++ /dev/null @@ -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__ diff --git a/ansible/roles/mongodb-old/defaults/main.yml b/ansible/roles/mongodb-old/defaults/main.yml deleted file mode 100644 index bb2a5c6..0000000 --- a/ansible/roles/mongodb-old/defaults/main.yml +++ /dev/null @@ -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 diff --git a/ansible/roles/mongodb-old/handlers/main.yml b/ansible/roles/mongodb-old/handlers/main.yml deleted file mode 100644 index bd6da46..0000000 --- a/ansible/roles/mongodb-old/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Save iptables rules - shell: iptables-save > /etc/iptables/rules.v4 diff --git a/ansible/roles/mongodb-old/tasks/backup.yml b/ansible/roles/mongodb-old/tasks/backup.yml deleted file mode 100644 index 30aea86..0000000 --- a/ansible/roles/mongodb-old/tasks/backup.yml +++ /dev/null @@ -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 }}' diff --git a/ansible/roles/mongodb-old/tasks/container.yml b/ansible/roles/mongodb-old/tasks/container.yml deleted file mode 100644 index df0e6c8..0000000 --- a/ansible/roles/mongodb-old/tasks/container.yml +++ /dev/null @@ -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' diff --git a/ansible/roles/mongodb-old/tasks/firewall.yml b/ansible/roles/mongodb-old/tasks/firewall.yml deleted file mode 100644 index e611641..0000000 --- a/ansible/roles/mongodb-old/tasks/firewall.yml +++ /dev/null @@ -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 diff --git a/ansible/roles/mongodb-old/tasks/main.yml b/ansible/roles/mongodb-old/tasks/main.yml deleted file mode 100644 index ac3901c..0000000 --- a/ansible/roles/mongodb-old/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- import_tasks: container.yml -- import_tasks: backup.yml -- import_tasks: firewall.yml