1
- Ansible role for MongoDB [ ![ Build Status] ( https://travis-ci.org/UnderGreen/ansible-role-mongodb.svg?branch=master )] ( https://travis-ci.org/UnderGreen/ansible-role-mongodb )
2
- ============
1
+ # Ansible role for MongoDB [ ![ Build Status] ( https://travis-ci.org/UnderGreen/ansible-role-mongodb.svg?branch=master )] ( https://travis-ci.org/UnderGreen/ansible-role-mongodb )
2
+
3
3
Ansible role which manages [ MongoDB] ( http://www.mongodb.org/ ) .
4
4
5
- * Install and configure the MongoDB;
6
- * Configure mongodb users
7
- * Configure replication
8
- * Provide handlers for restart and reload;
9
- * Setup MMS authomation agent;
5
+ - Install and configure the MongoDB;
6
+ - Configure mongodb users
7
+ - Configure replication
8
+ - Provide handlers for restart and reload;
9
+ - Setup MMS authomation agent;
10
10
11
11
MongoDB support matrix:
12
12
13
- | Distribution | < MongoDB 3.0 | MongoDB 3.2 | MongoDB 3.4 | MongoDB 3.6 | MongoDB 4.0 |
14
- | ------------ | :-------------:| :-----------:| :-----------:| :-----------:| :-----------:|
15
- | Ubuntu 14.04 | :no_entry : | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
16
- | Ubuntu 16.04 | :no_entry : | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
17
- | Ubuntu 18.04 | :no_entry : | :no_entry : | :x : | :white_check_mark : | :white_check_mark : |
18
- | Debian 8.x | :no_entry : | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
19
- | Debian 9.x | :no_entry : | :no_entry : | :x : | :white_check_mark : | :white_check_mark : |
20
- | RHEL 6.x | :no_entry : | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
21
- | RHEL 7.x | :no_entry : | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
13
+ | Distribution | < MongoDB 3.2 | MongoDB 3.4 | MongoDB 3.6 | MongoDB 4.0 |
14
+ | -------------- | :-----------: | :----------------: | :----------------: | :----------------: |
15
+ | Ubuntu 14.04 | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
16
+ | Ubuntu 16.04 | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
17
+ | Ubuntu 18.04 | :no_entry : | :x : | :white_check_mark : | :white_check_mark : |
18
+ | Debian 8.x | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
19
+ | Debian 9.x | :no_entry : | :x : | :white_check_mark : | :white_check_mark : |
20
+ | RHEL 6.x | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
21
+ | RHEL 7.x | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
22
+ | Amazon Linux 2 | :no_entry : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
22
23
23
24
- :white_check_mark : - fully tested, should works fine
24
25
- :interrobang : - maybe works, not tested
@@ -38,9 +39,9 @@ mongodb_package: mongodb-org
38
39
# I will recommend you to use latest version of MongoDB.
39
40
mongodb_version : " 3.6"
40
41
41
- mongodb_pymongo_from_pip : true # Install latest PyMongo via PIP or package manager
42
- mongodb_pymongo_pip_version : 3.6.1 # Choose PyMong version to install from pip. If not set use latest
43
- mongodb_user_update_password : " on_create" # MongoDB user password update default policy
42
+ mongodb_pymongo_from_pip : true # Install latest PyMongo via PIP or package manager
43
+ mongodb_pymongo_pip_version : 3.6.1 # Choose PyMong version to install from pip. If not set use latest
44
+ mongodb_user_update_password : " on_create" # MongoDB user password update default policy
44
45
mongodb_manage_service : true
45
46
46
47
# Disable transparent hugepages on systemd debian based installations
@@ -51,54 +52,58 @@ mongodb_uid:
51
52
mongodb_gid :
52
53
mongodb_daemon_name : " {{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"
53
54
# # net Options
54
- mongodb_net_bindip : 127.0.0.1 # Comma separated list of ip addresses to listen on
55
- mongodb_net_http_enabled : false # Enable http interface
56
- mongodb_net_ipv6 : false # Enable IPv6 support (disabled by default)
57
- mongodb_net_maxconns : 65536 # Max number of simultaneous connections
58
- mongodb_net_port : 27017 # Specify port number
55
+ mongodb_net_bindip : 127.0.0.1 # Comma separated list of ip addresses to listen on
56
+ mongodb_net_http_enabled : false # Enable http interface
57
+ mongodb_net_ipv6 : false # Enable IPv6 support (disabled by default)
58
+ mongodb_net_maxconns : 65536 # Max number of simultaneous connections
59
+ mongodb_net_port : 27017 # Specify port number
59
60
60
61
# # processManagement Options
61
- mongodb_processmanagement_fork : false # Fork server process
62
+ mongodb_processmanagement_fork : false # Fork server process
62
63
63
64
# # security Options
64
65
# Disable or enable security. Possible values: 'disabled', 'enabled'
65
66
mongodb_security_authorization : " disabled"
66
- mongodb_security_keyfile : /etc/mongodb-keyfile # Specify path to keyfile with password for inter-process authentication
67
+ mongodb_security_keyfile : /etc/mongodb-keyfile # Specify path to keyfile with password for inter-process authentication
67
68
68
69
# # storage Options
69
- mongodb_storage_dbpath : /data/db # Directory for datafiles
70
- mongodb_storage_dirperdb : false # Use one directory per DB
70
+ mongodb_storage_dbpath : /data/db # Directory for datafiles
71
+ mongodb_storage_dirperdb : false # Use one directory per DB
71
72
72
73
# The storage engine for the mongod database. Available values:
73
74
# 'mmapv1', 'wiredTiger'
74
75
mongodb_storage_engine : " {{ 'mmapv1' if mongodb_version[0:3] == '3.0' else 'wiredTiger' }}"
75
76
# mmapv1 specific options
76
- mongodb_storage_quota_enforced : false # Limits each database to a certain number of files
77
- mongodb_storage_quota_maxfiles : 8 # Number of quota files per DB
78
- mongodb_storage_smallfiles : false # Very useful for non-data nodes
77
+ mongodb_storage_quota_enforced : false # Limits each database to a certain number of files
78
+ mongodb_storage_quota_maxfiles : 8 # Number of quota files per DB
79
+ mongodb_storage_smallfiles : false # Very useful for non-data nodes
79
80
80
- mongodb_storage_journal_enabled : true # Enable journaling
81
- mongodb_storage_prealloc : true # Disable data file preallocation
81
+ mongodb_storage_journal_enabled : true # Enable journaling
82
+ mongodb_storage_prealloc : true # Disable data file preallocation
82
83
83
84
# WiredTiger Options
84
- mongodb_wiredtiger_cache_size : 1 # Cache size for wiredTiger in GB
85
+ mongodb_wiredtiger_cache_size : 1 # Cache size for wiredTiger in GB
85
86
86
87
# # systemLog Options
87
88
# # The destination to which MongoDB sends all log output. Specify either 'file' or 'syslog'.
88
89
# # If you specify 'file', you must also specify mongodb_systemlog_path.
89
90
mongodb_systemlog_destination : " file"
90
- mongodb_systemlog_logappend : true # Append to logpath instead of over-writing
91
- mongodb_systemlog_path : /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
91
+ mongodb_systemlog_logappend : true # Append to logpath instead of over-writing
92
+ mongodb_systemlog_path : /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
92
93
93
94
# # replication Options
94
- mongodb_replication_replset : # Enable replication <setname>[/<optionalseedhostlist>]
95
- mongodb_replication_replindexprefetch : " all" # specify index prefetching behavior (if secondary) [none|_id_only|all]
96
- mongodb_replication_oplogsize : 1024 # specifies a maximum size in megabytes for the replication operation log
95
+ mongodb_replication_replset : # Enable replication <setname>[/<optionalseedhostlist>]
96
+ mongodb_replication_replindexprefetch : " all" # specify index prefetching behavior (if secondary) [none|_id_only|all]
97
+ mongodb_replication_oplogsize : 1024 # specifies a maximum size in megabytes for the replication operation log
97
98
98
99
# # setParameter options
99
100
# Configure setParameter option.
100
101
# Example :
101
- mongodb_set_parameters : { "enableLocalhostAuthBypass": "true", "authenticationMechanisms": "SCRAM-SHA-1,MONGODB-CR" }
102
+ mongodb_set_parameters :
103
+ {
104
+ " enableLocalhostAuthBypass " : " true" ,
105
+ " authenticationMechanisms " : " SCRAM-SHA-1,MONGODB-CR" ,
106
+ }
102
107
103
108
# MMS Agent
104
109
mongodb_mms_agent_pkg : https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_7.2.0.488-1_amd64.ubuntu1604.deb
@@ -107,7 +112,7 @@ mongodb_mms_api_key: ""
107
112
mongodb_mms_base_url : https://mms.mongodb.com
108
113
109
114
# Log rotation
110
- mongodb_logrotate : true # Rotate mongodb logs.
115
+ mongodb_logrotate : true # Rotate mongodb logs.
111
116
mongodb_logrotate_options :
112
117
- compress
113
118
- copytruncate
@@ -149,6 +154,7 @@ mongodb_root_admin_password: passw0rd
149
154
Add ` undergreen.mongodb` to your roles and set vars in your playbook file.
150
155
151
156
Example vars for authorization :
157
+
152
158
` ` ` yaml
153
159
mongodb_security_authorization: "enabled"
154
160
mongodb_users:
@@ -159,15 +165,19 @@ mongodb_users:
159
165
database: app_development
160
166
}
161
167
` ` `
168
+
162
169
Example vars for oplog user :
170
+
163
171
` ` ` yaml
164
172
mongodb_oplog_users:
165
173
- {
166
174
user: oplog,
167
175
password: passw0rd
168
176
}
169
177
` ` `
178
+
170
179
Required vars to change on production :
180
+
171
181
` ` ` yaml
172
182
mongodb_user_admin_password
173
183
mongodb_root_admin_password
@@ -176,17 +186,25 @@ mongodb_root_backup_password
176
186
# if you use replication and authorization
177
187
mongodb_security_keyfile
178
188
` ` `
189
+
179
190
Example vars for replication :
191
+
180
192
` ` ` yaml
181
193
# It's a 'master' node
182
194
mongodb_login_host: 192.168.56.2
183
195
184
196
# mongodb_replication_params should be configured on each replica set node
185
197
mongodb_replication_params:
186
- - { host_name: 192.168.56.2, host_port: "{{ mongodb_net_port }}", host_type: replica }
198
+ - {
199
+ host_name: 192.168.56.2,
200
+ host_port: "{{ mongodb_net_port }}",
201
+ host_type: replica,
202
+ }
187
203
# host_type can be replica(default) and arbiter
188
204
` ` `
205
+
189
206
And inventory file for replica set :
207
+
190
208
` ` ` ini
191
209
[mongo_master]
192
210
192.158.56.2 mongodb_master=True # it is't a really master of MongoDB replica set,
0 commit comments