Skip to content

Commit b74bade

Browse files
committed
Introduce support for RedHat package installation
This provides initial support for installing the relevant MongoDB packages for a RedHat based OS. This currently only supports RHEL/CentOS 6 in order to keep the initial scope relatively constrained.
1 parent 52b1f39 commit b74bade

File tree

6 files changed

+85
-4
lines changed

6 files changed

+85
-4
lines changed

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ env:
2727
DISTRIBUTION=ubuntu-upstart
2828
DIST_VERSION=12.04
2929
MONGODB_VERSION=2.6
30+
- >
31+
DISTRIBUTION=centos
32+
DIST_VERSION=6
33+
MONGODB_VERSION=2.6
34+
- >
35+
DISTRIBUTION=centos
36+
DIST_VERSION=6
37+
MONGODB_VERSION=3.0
38+
- >
39+
DISTRIBUTION=centos
40+
DIST_VERSION=6
41+
MONGODB_VERSION=3.2
42+
- >
43+
DISTRIBUTION=centos
44+
DIST_VERSION=7
45+
MONGODB_VERSION=2.6
46+
- >
47+
DISTRIBUTION=centos
48+
DIST_VERSION=7
49+
MONGODB_VERSION=3.0
50+
- >
51+
DISTRIBUTION=centos
52+
DIST_VERSION=7
53+
MONGODB_VERSION=3.2
3054
# - >
3155
# distribution=ubuntu-upstart
3256
# version=12.04

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
command: cat /proc/1/cmdline
75
register: systemd

tasks/install.redhat.yml

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

tasks/main.yml

Lines changed: 7 additions & 2 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

templates/mongodb.repo.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[mongodb-org-{{ mongodb_version }}]
2+
name=MongoDB {{ mongodb_version }} Repository
3+
baseurl={{ mongodb_repository[item] }}
4+
gpgcheck={{ mongodb_repository_gpgkey[item] is defined | ternary(1,0) }}
5+
{% if mongodb_repository_gpgkey[item] is defined %}
6+
gpgkey={{ mongodb_repository_gpgkey[item] }}
7+
{% endif %}
8+
enabled=1

vars/RedHat.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
mongodb_repository:
4+
"2.6": "http://downloads-distro.mongodb.org/repo/redhat/os/$basearch/"
5+
"3.0": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/$basearch/"
6+
"3.2": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/$basearch/"
7+
8+
mongodb_repository_gpgkey:
9+
"3.2": "https://www.mongodb.org/static/pgp/server-3.2.asc"

0 commit comments

Comments
 (0)