-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.yml
63 lines (55 loc) · 1.44 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
# This playbook deploy a secure mongodb replica set on Ubuntu hosts
# Install mongodb on each nodes
- hosts: all
remote_user: mongors
sudo: True
roles:
- role: install-mongod-wt-rs
# Restart Primary taking into account the new configuration (/etc/mongod.conf)
- hosts: primary
remote_user: mongors
sudo: true
roles:
- role: restart_mongod
- role: wait_connection
# Initiate the replicaset and create the admin users
- hosts: primary
remote_user: mongors
sudo: True
roles:
- role: initiate-replica-set
- role: wait_master
- role: create_admin_users
# Create key file
- hosts: localhost
tasks:
- name: create key file locally
local_action: shell openssl rand -base64 755 > /tmp/mongodb-keyfile
# Copy key file to each node
- hosts: all
remote_user: mongors
sudo: True
roles:
- role: set_key_files
# Restart Primary taking into account the new configuration (auth / keyFile option defined in /etc/mongod.conf)
- hosts: primary
remote_user: mongors
sudo: true
roles:
- role: restart_mongod
- role: wait_master
# Restart Secondaries taking into account the new configuration (auth / keyFile option defined in /etc/mongod.conf)
- hosts: secondary
remote_user: mongors
sudo: true
roles:
- role: restart_mongod
- role: wait_connection
# Add members to the replicaset and create user for the database
- hosts: primary
remote_user: mongors
sudo: True
roles:
- role: add-members
- role: create_users