Skip to content

Commit 3cfe431

Browse files
authored
Merge pull request #159 from thiagoalmeidasa/master
Adding amazonlinux support
2 parents daac15c + 444b7e2 commit 3cfe431

File tree

7 files changed

+159
-60
lines changed

7 files changed

+159
-60
lines changed

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# .travis.yml
22
---
3-
43
dist: trusty
54
sudo: required
65
language: python
@@ -86,6 +85,18 @@ env:
8685
DISTRIBUTION=centos
8786
DIST_VERSION=7-builded
8887
MONGODB_VERSION=3.4
88+
- >
89+
DISTRIBUTION=amazonlinux
90+
DIST_VERSION=2-builded
91+
MONGODB_VERSION=4.0
92+
- >
93+
DISTRIBUTION=amazonlinux
94+
DIST_VERSION=2-builded
95+
MONGODB_VERSION=3.6
96+
- >
97+
DISTRIBUTION=amazonlinux
98+
DIST_VERSION=2-builded
99+
MONGODB_VERSION=3.4
89100
90101
services:
91102
- docker

README.md

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
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+
33
Ansible role which manages [MongoDB](http://www.mongodb.org/).
44

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;
1010

1111
MongoDB support matrix:
1212

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: |
2223

2324
- :white_check_mark: - fully tested, should works fine
2425
- :interrobang: - maybe works, not tested
@@ -38,9 +39,9 @@ mongodb_package: mongodb-org
3839
# I will recommend you to use latest version of MongoDB.
3940
mongodb_version: "3.6"
4041

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
4445
mongodb_manage_service: true
4546

4647
# Disable transparent hugepages on systemd debian based installations
@@ -51,54 +52,58 @@ mongodb_uid:
5152
mongodb_gid:
5253
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"
5354
## 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
5960

6061
## processManagement Options
61-
mongodb_processmanagement_fork: false # Fork server process
62+
mongodb_processmanagement_fork: false # Fork server process
6263

6364
## security Options
6465
# Disable or enable security. Possible values: 'disabled', 'enabled'
6566
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
6768

6869
## 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
7172

7273
# The storage engine for the mongod database. Available values:
7374
# 'mmapv1', 'wiredTiger'
7475
mongodb_storage_engine: "{{ 'mmapv1' if mongodb_version[0:3] == '3.0' else 'wiredTiger' }}"
7576
# 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
7980

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
8283

8384
# 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
8586

8687
## systemLog Options
8788
## The destination to which MongoDB sends all log output. Specify either 'file' or 'syslog'.
8889
## If you specify 'file', you must also specify mongodb_systemlog_path.
8990
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
9293

9394
## 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
9798

9899
## setParameter options
99100
# Configure setParameter option.
100101
# 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+
}
102107

103108
# MMS Agent
104109
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: ""
107112
mongodb_mms_base_url: https://mms.mongodb.com
108113

109114
# Log rotation
110-
mongodb_logrotate: true # Rotate mongodb logs.
115+
mongodb_logrotate: true # Rotate mongodb logs.
111116
mongodb_logrotate_options:
112117
- compress
113118
- copytruncate
@@ -149,6 +154,7 @@ mongodb_root_admin_password: passw0rd
149154
Add `undergreen.mongodb` to your roles and set vars in your playbook file.
150155

151156
Example vars for authorization:
157+
152158
```yaml
153159
mongodb_security_authorization: "enabled"
154160
mongodb_users:
@@ -159,15 +165,19 @@ mongodb_users:
159165
database: app_development
160166
}
161167
```
168+
162169
Example vars for oplog user:
170+
163171
```yaml
164172
mongodb_oplog_users:
165173
- {
166174
user: oplog,
167175
password: passw0rd
168176
}
169177
```
178+
170179
Required vars to change on production:
180+
171181
```yaml
172182
mongodb_user_admin_password
173183
mongodb_root_admin_password
@@ -176,17 +186,25 @@ mongodb_root_backup_password
176186
# if you use replication and authorization
177187
mongodb_security_keyfile
178188
```
189+
179190
Example vars for replication:
191+
180192
```yaml
181193
# It's a 'master' node
182194
mongodb_login_host: 192.168.56.2
183195
184196
# mongodb_replication_params should be configured on each replica set node
185197
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+
}
187203
# host_type can be replica(default) and arbiter
188204
```
205+
189206
And inventory file for replica set:
207+
190208
```ini
191209
[mongo_master]
192210
192.158.56.2 mongodb_master=True # it is't a really master of MongoDB replica set,

meta/main.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
dependencies: []
43

54
galaxy_info:
@@ -9,19 +8,23 @@ galaxy_info:
98
license: GPLv2
109
min_ansible_version: 2.4
1110
platforms:
12-
- name: Ubuntu
13-
versions:
14-
- trusty
15-
- xenial
16-
- bionic
17-
- name: Debian
18-
versions:
19-
- jessie
20-
- stretch
21-
- name: EL
22-
versions:
23-
- 6
24-
- 7
11+
- name: Ubuntu
12+
versions:
13+
- trusty
14+
- xenial
15+
- bionic
16+
- name: Debian
17+
versions:
18+
- jessie
19+
- stretch
20+
- name: EL
21+
versions:
22+
- 6
23+
- 7
24+
- name: Amazon
25+
versions:
26+
- Candidate
2527
galaxy_tags:
26-
- database
27-
- database:nosql
28+
- database
29+
- nosql
30+
- mongodb

tasks/install.amazon.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
- name: Establish some role-related facts
3+
set_fact:
4+
mongodb_major_version: "{{ mongodb_version[0:3] }}"
5+
6+
- name: Add YUM repository
7+
template:
8+
src: mongodb.repo.j2
9+
dest: /etc/yum.repos.d/mongodb.repo
10+
mode: 0644
11+
with_items: "{{ mongodb_version[0:3] }}"
12+
when: mongodb_package == 'mongodb-org'
13+
14+
- name: Install MongoDB package
15+
yum:
16+
name:
17+
- "{{ mongodb_package }}"
18+
- numactl
19+
state: present
20+
21+
- name: Install PyMongo package
22+
yum:
23+
name: python-pymongo
24+
state: latest
25+
when: not mongodb_pymongo_from_pip
26+
27+
- name: Install PIP
28+
yum:
29+
name:
30+
- python-devel
31+
- python-pip
32+
when: mongodb_pymongo_from_pip
33+
34+
- name: Install PyMongo from PIP
35+
pip:
36+
name: pymongo
37+
state: "{{ mongodb_pymongo_pip_version is defined | ternary('present', 'latest') }}"
38+
version: "{{ mongodb_pymongo_pip_version | default(omit) }}"
39+
when: mongodb_pymongo_from_pip

tasks/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
- "{{ ansible_os_family }}.yml"
99

1010
- name: Include installation tasks
11-
include: "install.{{ ansible_os_family | lower }}.yml"
11+
include: "{{ item }}"
12+
with_first_found:
13+
- "install.{{ ansible_distribution | lower }}.yml"
14+
- "install.{{ ansible_os_family | lower }}.yml"
1215
tags: [mongodb]
1316

1417
- name: Include configuration.yml
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM amazonlinux:2
2+
3+
# This is needed so that ansible managed to read "ansible_default_ipv4"
4+
RUN yum install iproute -y
5+
6+
# This step is needed since standard CentOS docker image does not come with init-functions installed by default.
7+
# This package seems to be required for Mongo 3.2 and downwards
8+
RUN yum install initscripts -y
9+
10+
# we can has SSH
11+
EXPOSE 22
12+
13+
# pepare for takeoff
14+
CMD ["/usr/sbin/init"]

vars/Amazon.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
mongodb_repository:
3+
"4.0": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.0/x86_64/"
4+
"3.6": "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/"
5+
"3.4": "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.4/x86_64/"
6+
7+
mongodb_repository_gpgkey:
8+
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
9+
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"
10+
11+
mongodb_pidfile_path: "{{ '/var/run/mongodb/mongod.pid' if ('mongodb-org' in mongodb_package) else '' }}"

0 commit comments

Comments
 (0)