1
1
Ansible role for MongoDB
2
2
============
3
- This repository forked from [ Stouts.mongodb] ( https://github.com/Stouts/Stouts.mongodb ) .
4
- Ansible role which manage [ MongoDB] ( http://www.mongodb.org/ )
3
+ Ansible role which manage [ MongoDB] ( http://www.mongodb.org/ ) .
5
4
6
5
* Install and configure the MongoDB;
7
6
* Provide handlers for restart and reload;
@@ -10,10 +9,20 @@ Ansible role which manage [MongoDB](http://www.mongodb.org/)
10
9
#### Variables
11
10
12
11
``` yaml
12
+ # You can use this variable to control installation source of MongoDB
13
+ # 'mongodb' will be installed from Debian/Ubuntu repos
14
+ # 'mongodb-org' will be installed from MongoDB official repos
13
15
mongodb_package : mongodb-org
14
16
17
+ # You can control installed version via this param.
18
+ # Should be '2.6', '3.0' or '3.2'. This role does't support MongoDB < 2.4.
19
+ # I will recommend you to use latest version of MongoDB.
20
+ mongodb_version : " 3.2"
21
+
15
22
mongodb_force_wait_for_port : false # When not forced, the role will wait for mongod port to become available only with systemd
16
- mongodb_pymongo_from_pip : false # Install latest PyMongo via PIP or package manager
23
+ mongodb_pymongo_from_pip : true # Install latest PyMongo via PIP or package manager
24
+ mongodb_pymongo_pip_version : " 3.2.2"
25
+
17
26
mongodb_disable_thp : true
18
27
19
28
mongodb_manage_service : true
@@ -22,32 +31,45 @@ mongodb_user: mongodb
22
31
mongodb_uid :
23
32
mongodb_gid :
24
33
mongodb_daemon_name : " {{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"
25
-
26
- mongodb_conf_auth : false # Run with security
27
- mongodb_conf_bind_ip : 127.0.0.1 # Comma separated list of ip addresses to listen on
28
- mongodb_conf_cpu : true # Periodically show cpu and iowait utilization
29
- mongodb_conf_dbpath : /data/db # Directory for datafiles
30
- mongodb_conf_fork : false # Fork server process
31
- mongodb_conf_httpinterface : false # Enable http interface
32
- mongodb_conf_ipv6 : false # Enable IPv6 support (disabled by default)
33
- mongodb_conf_journal : true # Enable journaling
34
- mongodb_conf_logappend : true # Append to logpath instead of over-writing
35
- mongodb_conf_logpath : /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
36
- mongodb_conf_maxConns : 1000000 # Max number of simultaneous connections
37
- mongodb_conf_noprealloc : false # Disable data file preallocation
38
- mongodb_conf_smallfiles : false # Disable smallfiles option
39
- mongodb_conf_noscripting : false # Disable scripting engine
40
- mongodb_conf_notablescan : false # Do not allow table scans
41
- mongodb_conf_port : 27017 # Specify port number
42
- mongodb_conf_quota : false # Limits each database to a certain number of files
43
- mongodb_conf_quotaFiles : 8 # Number of quota files
44
- mongodb_conf_syslog : false # Log to system's syslog facility instead of file
45
-
46
- # Replica set options:
47
- mongodb_conf_replSet : # Enable replication <setname>[/<optionalseedhostlist>]
48
- mongodb_conf_replIndexPrefetch : " all" # specify index prefetching behavior (if secondary) [none|_id_only|all]
49
- mongodb_conf_oplogSize : 512 # specifies a maximum size in megabytes for the replication operation log
50
- mongodb_conf_keyFile : /etc/mongodb-keyfile # Specify path to keyfile with password for inter-process authentication
34
+ # # net Options
35
+ mongodb_net_bindip : 127.0.0.1 # Comma separated list of ip addresses to listen on
36
+ mongodb_net_http_enabled : false # Enable http interface
37
+ mongodb_net_ipv6 : false # Enable IPv6 support (disabled by default)
38
+ mongodb_net_maxconns : 65536 # Max number of simultaneous connections
39
+ mongodb_net_port : 27017 # Specify port number
40
+
41
+ # # processManagement Options
42
+ mongodb_processmanagement_fork : false # Fork server process
43
+
44
+ # # security Options
45
+ # Disable or enable security. Possible values: 'disabled', 'enabled'
46
+ mongodb_security_authorization : " disabled"
47
+ mongodb_security_keyfile : /etc/mongodb-keyfile # Specify path to keyfile with password for inter-process authentication
48
+
49
+ # # storage Options
50
+ mongodb_storage_dbpath : /data/db # Directory for datafiles
51
+ # The storage engine for the mongod database. Available values:
52
+ # 'mmapv1', 'wiredTiger'
53
+ mongodb_storage_engine : " {{ 'mmapv1' if mongodb_version[0:3] == '3.0' else 'wiredTiger' }}"
54
+ # mmapv1 specific options
55
+ mongodb_storage_quota_enforced : false # Limits each database to a certain number of files
56
+ mongodb_storage_quota_maxfiles : 8 # Number of quota files per DB
57
+ mongodb_storage_smallfiles : false # Very useful for non-data nodes
58
+
59
+ mongodb_storage_journal_enabled : true # Enable journaling
60
+ mongodb_storage_prealloc : true # Disable data file preallocation
61
+
62
+ # # systemLog Options
63
+ # # The destination to which MongoDB sends all log output. Specify either 'file' or 'syslog'.
64
+ # # If you specify 'file', you must also specify mongodb_systemlog_path.
65
+ mongodb_systemlog_destination : " file"
66
+ mongodb_systemlog_logappend : true # Append to logpath instead of over-writing
67
+ mongodb_systemlog_path : /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
68
+
69
+ # # replication Options
70
+ mongodb_replication_replset : # Enable replication <setname>[/<optionalseedhostlist>]
71
+ mongodb_replication_replindexprefetch : " all" # specify index prefetching behavior (if secondary) [none|_id_only|all]
72
+ mongodb_replication_oplogsize : 1024 # specifies a maximum size in megabytes for the replication operation log
51
73
52
74
# MMS Agent
53
75
mongodb_mms_agent_pkg : https://mms.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_1.4.2.783-1_amd64.deb
@@ -99,7 +121,7 @@ Add `greendayonfire.mongodb` to your roles and set vars in your playbook file.
99
121
100
122
Example vars for authorization :
101
123
` ` ` yaml
102
- mongodb_conf_auth : true
124
+ mongodb_security_authorization : true
103
125
mongodb_users:
104
126
- {
105
127
name: testUser,
@@ -112,23 +134,34 @@ Required vars to change on production:
112
134
` ` ` yaml
113
135
mongodb_user_admin_password
114
136
mongodb_root_admin_password
137
+
138
+ # if you use replication and authorization
139
+ mongodb_security_keyfile
115
140
` ` `
116
141
Example vars for replication :
117
142
` ` ` yaml
143
+ # It's a 'master' node
144
+ mongodb_login_host: 192.168.56.2
145
+
118
146
# mongodb_replication_params should be configured on each replica set node
119
147
mongodb_replication_params:
120
- - { host_name: 192.168.56.2, host_port: "{{ mongodb_conf_port }}", host_type: replica }
148
+ - { host_name: 192.168.56.2, host_port: "{{ mongodb_net_port }}", host_type: replica }
121
149
# host_type can be replica(default) and arbiter
122
150
` ` `
123
151
And inventory file for replica set :
124
152
` ` ` ini
125
153
[mongo_master]
126
- 192.158.56.2 mongodb_master=True # it'n not a really master of MongoDB replica set,
154
+ 192.158.56.2 mongodb_master=True # it is't a really master of MongoDB replica set,
127
155
# use this variable for replica set init only
156
+ # or when master is moved from initial master node
128
157
129
158
[mongo_replicas]
130
159
192.168.56.3
131
160
192.168.56.4
161
+
162
+ [mongo:children]
163
+ mongo_master
164
+ mongo_replicas
132
165
` ` `
133
166
134
167
Licensed under the GPLv2 License. See the [LICENSE.md](LICENSE.md) file for details.
0 commit comments