configure prod MongoDB replicate set

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-08-01 14:12:39 -04:00
parent 20a59a1e2c
commit efe0c3269b
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
5 changed files with 25 additions and 3 deletions

View File

@ -1,6 +1,6 @@
--- ---
- name: Configure MongoDB - name: Configure MongoDB dev cluster
hosts: mongodb hosts: db.dev
roles: roles:
- mongodb-firewall - mongodb-firewall
- mongodb-setup - mongodb-setup

View File

@ -1,6 +1,7 @@
--- ---
# versions # versions
mongodb_version: "4.0" mongodb_version: "4.0"
# Fixes: https://github.com/ansible/ansible/issues/44970
mongodb_pymongo_pip_version: 3.8.0 mongodb_pymongo_pip_version: 3.8.0
# listening address & port # listening address & port
@ -33,11 +34,15 @@ mongodb_oplog_users:
mongodb_login_host_vars: '{{ hostvars[groups["db.prod"][0]] }}' mongodb_login_host_vars: '{{ hostvars[groups["db.prod"][0]] }}'
mongodb_login_host: '{{ mongodb_login_host_vars["dns_entry"] }}' mongodb_login_host: '{{ mongodb_login_host_vars["dns_entry"] }}'
# TODO generate this dynamically
mongodb_replication_params: mongodb_replication_params:
- host_name: '{{ hostvars[groups["db.prod"][0]].dns_entry }}'
- host_name: '{{ hostvars[groups["db.prod"][1]].dns_entry }}' - host_name: '{{ hostvars[groups["db.prod"][1]].dns_entry }}'
- host_name: '{{ hostvars[groups["db.prod"][2]].dns_entry }}' - host_name: '{{ hostvars[groups["db.prod"][2]].dns_entry }}'
# avoid having to auth on localhost
mongodb_set_parameters:
enableLocalhostAuthBypass: "true"
# backups auth # backups auth
mongodb_backup_db_name: '{{ mongodb_users[0].database }}' mongodb_backup_db_name: '{{ mongodb_users[0].database }}'
mongodb_backup_db_user: '{{ mongodb_users[0].name }}' mongodb_backup_db_user: '{{ mongodb_users[0].name }}'

View File

@ -0,0 +1,4 @@
---
# use this variable for replica set init only
# or when master is moved from initial master node
mongodb_master: true

11
ansible/prod.yml Normal file
View File

@ -0,0 +1,11 @@
---
- name: Configure MongoDB prod cluster
hosts: db.prod
roles:
- mongodb-firewall
- mongodb-setup
- mongodb-backups
post_tasks:
- name: MongoDB URI string
debug:
msg: 'mongodb://{{ mongodb_users[0].name }}:{{ mongodb_users[0].password }}@{{ dns_entry }}:{{ mongodb_net_port }}/{{ mongodb_users[0].database }}'

View File

@ -19,6 +19,8 @@
src: git@github.com:status-im/infra-role-s3cmd-backup.git src: git@github.com:status-im/infra-role-s3cmd-backup.git
scm: git scm: git
# WARNING: Fails if python3 is the default
# Details:
- name: mongodb-setup - name: mongodb-setup
src: https://github.com/UnderGreen/ansible-role-mongodb.git src: https://github.com/UnderGreen/ansible-role-mongodb.git
scm: git scm: git