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.
This commit is contained in:
Daniel White 2016-04-27 14:45:25 +10:00
parent 52b1f395ea
commit b74bade421
6 changed files with 85 additions and 4 deletions

View File

@ -27,6 +27,30 @@ env:
DISTRIBUTION=ubuntu-upstart DISTRIBUTION=ubuntu-upstart
DIST_VERSION=12.04 DIST_VERSION=12.04
MONGODB_VERSION=2.6 MONGODB_VERSION=2.6
- >
DISTRIBUTION=centos
DIST_VERSION=6
MONGODB_VERSION=2.6
- >
DISTRIBUTION=centos
DIST_VERSION=6
MONGODB_VERSION=3.0
- >
DISTRIBUTION=centos
DIST_VERSION=6
MONGODB_VERSION=3.2
- >
DISTRIBUTION=centos
DIST_VERSION=7
MONGODB_VERSION=2.6
- >
DISTRIBUTION=centos
DIST_VERSION=7
MONGODB_VERSION=3.0
- >
DISTRIBUTION=centos
DIST_VERSION=7
MONGODB_VERSION=3.2
# - > # - >
# distribution=ubuntu-upstart # distribution=ubuntu-upstart
# version=12.04 # version=12.04

View File

@ -1,7 +1,5 @@
--- ---
- include_vars: "{{ansible_distribution}}.yml"
- name: Check if running on systemd - name: Check if running on systemd
command: cat /proc/1/cmdline command: cat /proc/1/cmdline
register: systemd register: systemd

37
tasks/install.redhat.yml Normal file
View File

@ -0,0 +1,37 @@
---
- name: Add YUM repository
template:
src: mongodb.repo.j2
dest: /etc/yum.repos.d/mongodb.repo
mode: 0644
with_items: "{{ mongodb_version[0:3] }}"
when: mongodb_package == 'mongodb-org'
- name: Install MongoDB package
yum:
name: "{{ item }}"
state: present
with_items:
- "{{ mongodb_package }}"
- numactl
- name: Install PyMongo package
yum:
name: python-pymongo
state: latest
when: not mongodb_pymongo_from_pip
- name: Install PIP
yum:
name: "{{ item }}"
with_items:
- python-devel
- python-pip
when: mongodb_pymongo_from_pip
- name: Install PyMongo from PIP
pip:
name: pymongo
state: latest
when: mongodb_pymongo_from_pip

View File

@ -1,8 +1,13 @@
--- ---
- name: Include OS-specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- name: Include installation on Debian-based OS - name: Include installation on Debian-based OS
include: install.deb.yml include: "install.{{ ansible_os_family | lower }}.yml"
when: ansible_os_family == 'Debian'
tags: [mongodb] tags: [mongodb]
- name: Include configuration.yml - name: Include configuration.yml

View File

@ -0,0 +1,8 @@
[mongodb-org-{{ mongodb_version }}]
name=MongoDB {{ mongodb_version }} Repository
baseurl={{ mongodb_repository[item] }}
gpgcheck={{ mongodb_repository_gpgkey[item] is defined | ternary(1,0) }}
{% if mongodb_repository_gpgkey[item] is defined %}
gpgkey={{ mongodb_repository_gpgkey[item] }}
{% endif %}
enabled=1

9
vars/RedHat.yml Normal file
View File

@ -0,0 +1,9 @@
---
mongodb_repository:
"2.6": "http://downloads-distro.mongodb.org/repo/redhat/os/$basearch/"
"3.0": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/$basearch/"
"3.2": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/$basearch/"
mongodb_repository_gpgkey:
"3.2": "https://www.mongodb.org/static/pgp/server-3.2.asc"