Skip to content

Commit 54a2e1e

Browse files
authored
Merge pull request #83 from justinsaliba/redhat-support
Redhat support
2 parents 9ba2bbc + 7c3cfd2 commit 54a2e1e

16 files changed

+195
-21
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
tests/*.retry
12
*~
23
\#*\#
34
.\#*
4-
/.python-version
5+
/.python-version

.travis.yml

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
sudo: required
55
env:
6+
- >
7+
DISTRIBUTION=ubuntu-upstart
8+
DIST_VERSION=14.04
9+
MONGODB_VERSION=3.4
610
- >
711
DISTRIBUTION=ubuntu-upstart
812
DIST_VERSION=14.04
@@ -15,6 +19,10 @@ env:
1519
DISTRIBUTION=ubuntu-upstart
1620
DIST_VERSION=14.04
1721
MONGODB_VERSION=2.6
22+
- >
23+
DISTRIBUTION=ubuntu-upstart
24+
DIST_VERSION=12.04-builded
25+
MONGODB_VERSION=3.4
1826
- >
1927
DISTRIBUTION=ubuntu-upstart
2028
DIST_VERSION=12.04-builded
@@ -27,6 +35,44 @@ env:
2735
DISTRIBUTION=ubuntu-upstart
2836
DIST_VERSION=12.04-builded
2937
MONGODB_VERSION=2.6
38+
- >
39+
DISTRIBUTION=centos
40+
DIST_VERSION=6-builded
41+
MONGODB_VERSION=2.6
42+
- >
43+
DISTRIBUTION=centos
44+
DIST_VERSION=6-builded
45+
MONGODB_VERSION=3.0
46+
- >
47+
DISTRIBUTION=centos
48+
DIST_VERSION=6-builded
49+
MONGODB_VERSION=3.2
50+
- >
51+
DISTRIBUTION=centos
52+
DIST_VERSION=6-builded
53+
MONGODB_VERSION=3.4
54+
- >
55+
DISTRIBUTION=centos
56+
DIST_VERSION=7-builded
57+
MONGODB_VERSION=2.6
58+
- >
59+
DISTRIBUTION=centos
60+
DIST_VERSION=7-builded
61+
MONGODB_VERSION=3.0
62+
- >
63+
DISTRIBUTION=centos
64+
DIST_VERSION=7-builded
65+
MONGODB_VERSION=3.2
66+
- >
67+
DISTRIBUTION=centos
68+
DIST_VERSION=7-builded
69+
MONGODB_VERSION=3.4
70+
# - >
71+
# distribution=ubuntu-upstart
72+
# version=12.04
73+
# - >
74+
# distribution=debian
75+
# version=7
3076

3177
services:
3278
- docker
@@ -44,16 +90,15 @@ before_install:
4490
sudo docker build --rm=true --file=tests/Dockerfile.${DISTRIBUTION}_${DIST_VERSION}
4591
--tag ${DISTRIBUTION}:${DIST_VERSION} tests; else sudo docker pull ${DISTRIBUTION}:${DIST_VERSION}; fi
4692
- sudo ln -s ${PWD} /etc/ansible/roles/greendayonfire.mongodb
47-
93+
4894
script:
4995
# Test 1
5096
- >
51-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION}
52-
-e image_name=${DISTRIBUTION}:${DIST_VERSION}
97+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION}
5398
# Idempotence test
5499
- >
55-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION}
56-
-e image_name=${DISTRIBUTION}:${DIST_VERSION} | grep -q 'changed=0.*failed=0'
100+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION}
101+
| grep -q 'changed=0.*failed=0'
57102
&& (echo 'Idempotence test: pass' && exit 0)
58103
|| (echo 'Idempotence test: fail' && exit 1)
59104

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ MongoDB support matrix:
1717
| Ubuntu 16.04 | :no_entry: | :x: | :x: | :x:| :x:|
1818
| Debian 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang:| :x:|
1919
| Debian 8.x | :no_entry: | :x: | :x: | :x:| :x:|
20+
| RHEL 6.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: |
21+
| RHEL 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: |
2022

2123
:white_check_mark: - fully tested, should work fine
2224
:interrobang: - will be added testing suite soon
@@ -41,7 +43,7 @@ mongodb_pymongo_from_pip: true # Install latest PyMongo via PI
4143
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
4244
mongodb_manage_service: true
4345

44-
mongodb_user: mongodb
46+
mongodb_user: "{{ 'mongod' if ('RedHat' == ansible_os_family) else 'mongodb' }}"
4547
mongodb_uid:
4648
mongodb_gid:
4749
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"

defaults/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mongodb_force_wait_for_port: false
1515
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
1616
mongodb_manage_service: true
1717

18-
mongodb_user: mongodb
18+
mongodb_user: "{{ 'mongod' if ('RedHat' == ansible_os_family) else 'mongodb' }}"
1919
mongodb_uid:
2020
mongodb_gid:
2121
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"
@@ -28,7 +28,9 @@ mongodb_net_maxconns: 65536 # Max number of simultaneous co
2828
mongodb_net_port: 27017 # Specify port number
2929

3030
## processManagement Options
31-
mongodb_processmanagement_fork: false # Fork server process
31+
# Fork server process
32+
# Enabled by default for RedHat as the init scripts assume forking is enabled.
33+
mongodb_processmanagement_fork: "{{ 'RedHat' == ansible_os_family }}"
3234

3335
## security Options
3436
# Disable or enable security. Possible values: 'disabled', 'enabled'

meta/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ galaxy_info:
1616
- name: Debian
1717
versions:
1818
- wheezy
19+
- name: EL
20+
versions:
21+
- 6
22+
- 7
1923
galaxy_tags:
2024
- database
2125
- database:nosql

tasks/install.deb.yml renamed to tasks/install.debian.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
---
22

3-
- include_vars: "{{ansible_distribution}}.yml"
4-
53
- name: Check if running on systemd
64
stat: path=/sbin/init
75
register: sbin_init

tasks/install.redhat.yml

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

tasks/main.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
---
22

3+
- name: Include OS-specific variables
4+
include_vars: "{{ item }}"
5+
with_first_found:
6+
- "{{ ansible_distribution }}.yml"
7+
- "{{ ansible_os_family }}.yml"
8+
39
- name: Include installation on Debian-based OS
4-
include: install.deb.yml
5-
when: ansible_os_family == 'Debian'
10+
include: "install.{{ ansible_os_family | lower }}.yml"
611
tags: [mongodb]
712

813
- name: Include configuration.yml
@@ -22,11 +27,10 @@
2227
when: mongodb_replication_replset and mongodb_replication_replset != ''
2328
tags: [mongodb]
2429

25-
- name: Check user admin is exists
30+
- name: Check where admin user already exists
2631
command: >
2732
mongo --quiet -u {{ mongodb_user_admin_name }} \
2833
-p {{ mongodb_user_admin_password }} --port {{ mongodb_net_port }} --eval 'db.version()' admin
29-
3034
register: mongodb_user_admin_check
3135
changed_when: false
3236
always_run: yes # side-effect free, so it can be run in check-mode as well

tasks/mms-agent.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
---
22

3-
- name: Install MMS agent pt. 1
3+
- name: Download MMS Agent (Debian)
44
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.deb
55
register: mongodb_mms_agent_loaded
6+
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
67

7-
- name: Install MMS agent pt. 2
8-
apt: deb={{mongodb_storage_dbpath}}/mms-agent.deb
9-
when: mongodb_mms_agent_loaded.changed
8+
- name: Download MMS Agent (RHEL)
9+
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.rpm
10+
register: mongodb_mms_agent_loaded
11+
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
12+
13+
- name: Install MMS agent (Debian)
14+
apt:
15+
deb: "{{mongodb_storage_dbpath}}/mms-agent.deb"
16+
when: mongodb_mms_agent_loaded.changed and (ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu')
17+
18+
- name: Install MMS agent (RHEL)
19+
yum:
20+
name: "{{mongodb_storage_dbpath}}/mms-agent.rpm"
21+
state: present
22+
when: mongodb_mms_agent_loaded.changed and (ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux')
1023

1124
- name: Configure the MMS agent pt. 1
1225
file: state=directory path=/etc/mongodb-mms owner={{mongodb_user}} group={{mongodb_user}} mode=0755

templates/mongod.conf.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ net:
1010

1111
processManagement:
1212
fork: {{ mongodb_processmanagement_fork | to_nice_json}}
13+
{% if mongodb_pidfile_path is defined and mongodb_pidfile_path != '' -%}
14+
pidFilePath: {{ mongodb_pidfile_path }}
15+
{% endif %}
1316

1417
{% if mongodb_replication_replset -%}
1518
replication:

0 commit comments

Comments
 (0)