Skip to content

Commit

Permalink
Merge pull request #249 from UnderGreen/sergei/mongodb_44
Browse files Browse the repository at this point in the history
Add support of MongoDB 4.4
  • Loading branch information
UnderGreen authored Mar 20, 2021
2 parents 1f2f47e + 2dd49b5 commit 873fd19
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/workflows/amazonlinux2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
molecule_distro:
- amazonlinux2
mongodb_version:
- '4.4'
- '4.2'
- '4.0'
- '3.6'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- centos7
- centos8
mongodb_version:
- '4.4'
- '4.2'
- '4.0'
- '3.6'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- debian9
- debian10
mongodb_version:
- '4.4'
- '4.2'
- '4.0'
- '3.6'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
- '4.2'
- '4.0'
- '3.6'
include:
- molecule_distro: ubuntu2004
mongodb_version: '4.4'
env:
MONGODB_VERSION: ${{ matrix.mongodb_version }}
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
Expand Down
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
# Ansible role for MongoDB
![Centos](https://github.com/UnderGreen/ansible-role-mongodb/actions/workflows/centos.yml/badge.svg) ![Debian](https://github.com/UnderGreen/ansible-role-mongodb/actions/workflows/debian.yml/badge.svg)
# Ansible role for MongoDB
![Centos](https://github.com/UnderGreen/ansible-role-mongodb/actions/workflows/centos.yml/badge.svg) ![Debian](https://github.com/UnderGreen/ansible-role-mongodb/actions/workflows/debian.yml/badge.svg) ![Ubuntu](https://github.com/UnderGreen/ansible-role-mongodb/actions/workflows/ubuntu.yml/badge.svg) ![Amazon Linux 2](https://github.com/UnderGreen/ansible-role-mongodb/actions/workflows/amazonlinux2.yml/badge.svg)

Ansible role which manages [MongoDB](http://www.mongodb.org/).
Ansible role to install and manage [MongoDB](http://www.mongodb.org/).

- Install and configure the MongoDB;
- Install and configure the MongoDB
- Configure mongodb users
- Configure authentication
- Configure replication
- Provide handlers for restart and reload;
- Setup MMS automation agent;

MongoDB support matrix:

| Distribution | < MongoDB 3.4 | MongoDB 3.6 | MongoDB 4.0 | MongoDB 4.2 |
| -------------- | :-----------: | :----------------: | :----------------: | :----------------: |
| Ubuntu 16.04 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Ubuntu 18.04 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Debian 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Debian 10.x | :no_entry: | :x: | :x: | :white_check_mark: |
| RHEL 7.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| RHEL 8.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Amazon Linux 2 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

- :white_check_mark: - fully tested, should works fine
- :interrobang: - maybe works, not tested
| Distribution | < MongoDB 3.4 | MongoDB 3.6 | MongoDB 4.0 | MongoDB 4.2 | MongoDB 4.4 |
| -------------- | :-----------: | :----------------: | :----------------: | :----------------: | :----------------: |
| Ubuntu 16.04 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| Ubuntu 18.04 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| Ubuntu 20.04 | :no_entry: | :x: | :x: | :x: | :white_check_mark: |
| Debian 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Debian 10.x | :no_entry: | :x: | :x: | :white_check_mark: | :white_check_mark: |
| RHEL 7.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| RHEL 8.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Amazon Linux 2 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

- :white_check_mark: - fully tested
- :x: - don't have official support
- :no_entry: - MongoDB has reached EOL

#### Variables

```yaml
# You can use this variable to control installation source of MongoDB
# 'mongodb' will be installed from Debian/Ubuntu repos
# 'mongodb-org' will be installed from MongoDB official repos
# This variable is used to set source of MongoDB installation.
# 'mongodb' - version provided by Debian-based distributions from their official package repositories.
# 'mongodb-org' - version provided by MongoDB package repository.
# 'mongodb' is not included in th role test matrix and working of it is not guarantied.
mongodb_package: mongodb-org

# You can control installed version via this param.
# Should be '3.6', '4.0' or '4.2'. This role doesn't support MongoDB < 3.6.
# I will recommend you to use latest version of MongoDB.
mongodb_version: "4.2"
# `mongodb_version` variable sets version of MongoDB.
# Should be '3.6', '4.0', '4.2' or '4.4'. This role doesn't support MongoDB < 3.6.
# I would recommend you to use the latest version of MongoDB.
mongodb_version: "4.4"

mongodb_pymongo_from_pip: true # Install latest PyMongo via PIP or package manager
mongodb_pymongo_pip_version: 3.6.1 # Choose PyMong version to install from pip. If not set use latest
Expand Down
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

mongodb_package: mongodb-org
mongodb_package_state: present
mongodb_version: "4.2"
mongodb_version: "4.4"
mongodb_apt_keyserver: keyserver.ubuntu.com
mongodb_apt_key_id:
"3.6": "2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5"
"4.0": "9DA31620334BD75D9DCB49F368818C72E52529D4"
"4.2": "E162F504A20CDF15827F718D4B7C549A058F8B6B"
"4.4": "20691eec35216c63caf66ce1656408e390cfb1f5"

mongodb_pymongo_from_pip: true # Install latest PyMongo via PIP or package manager
mongodb_pymongo_pip_version: 3.11.3
Expand Down
2 changes: 1 addition & 1 deletion molecule/cluster/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ provisioner:
converge: ${MOLECULE_PLAYBOOK:-../default/converge.yml}
prepare: ${MOLECULE_PLAYBOOK:-../default/prepare.yml}
env:
MONGODB_VERSION: ${MONGODB_VERSION:-4.2}
MONGODB_VERSION: ${MONGODB_VERSION:-4.4}
MONGODB_PACKAGE: ${MONGODB_PACKAGE:-mongodb-org}
AUTH_STATE: ${AUTH_STATE:-disabled}
REPLICASET: ${REPLICASET:-testrs}
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ provisioner:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
prepare: ${MOLECULE_PLAYBOOK:-prepare.yml}
env:
MONGODB_VERSION: ${MONGODB_VERSION:-4.2}
MONGODB_VERSION: ${MONGODB_VERSION:-4.4}
MONGODB_PACKAGE: ${MONGODB_PACKAGE:-mongodb-org}
AUTH_STATE: ${AUTH_STATE:-disabled}
inventory:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
remote_user: root
become: yes
tasks:
- name: Install prerequisite packages for molecule testing for Debian/Ubuntu >= 18
- name: Install prerequisite packages for molecule testing on Debian or Ubuntu >= 18
apt:
update_cache: true
name:
Expand Down
14 changes: 7 additions & 7 deletions tasks/install.debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

- name: Fail when used wrong mongodb_version variable
fail:
msg: "mongodb_version variable should be '3.6' or '4.0' or '4.2'"
msg: "mongodb_version variable should be '3.6' or '4.0', '4.2' or '4.4'"
when: (mongodb_package == 'mongodb-org' and
(mongodb_version is not defined
or mongodb_repository[mongodb_major_version] is not defined))
Expand All @@ -38,18 +38,17 @@
update_cache: true

- name: Check if NUMA is available on host
shell: "set -o pipefail && find /proc -name numa_maps | wc -l"
args:
executable: /bin/bash
register: numa_number_lines
command: "ls -1 /proc/1/numa_maps"
register: numa_available
ignore_errors: true
changed_when: false
check_mode: no
when: mongodb_use_numa | bool

- name: Don't use NUMA if it is unavailable on host
set_fact:
mongodb_use_numa: false
when: (mongodb_use_numa | bool and numa_number_lines.stdout | int == 0)
when: (mongodb_use_numa | bool and numa_available.rc != 0)

- name: Install numactl package
apt:
Expand Down Expand Up @@ -81,7 +80,8 @@
notify:
- reload systemd

- name: Forcefully set mongodb_pymongo_from_pip to true on Debian 10
# Workaround for the idempotence issue on Debian 10 with pip module
- name: Forcefully set mongodb_pymongo_from_pip to false on Debian 10
set_fact:
mongodb_pymongo_from_pip: false
when:
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
when: mongodb_replication_replset | length > 0
tags: [mongodb]

- name: Check where admin user already exists
- name: Check whether admin user is already exist
command: >
mongo --quiet {{ '--ssl --host ' + mongodb_net_ssl_host if mongodb_net_ssl_mode == 'requireSSL' else '' }} -u {{ mongodb_user_admin_name }} \
-p {{ mongodb_user_admin_password }} --port {{ mongodb_net_port }} --eval 'db.version()' admin
Expand Down
2 changes: 2 additions & 0 deletions vars/Amazon.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
mongodb_repository:
"4.4": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/x86_64/"
"4.2": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.2/x86_64/"
"4.0": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.0/x86_64/"
"3.6": "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/"

mongodb_repository_gpgkey:
"4.4": "https://www.mongodb.org/static/pgp/server-4.4.asc"
"4.2": "https://www.mongodb.org/static/pgp/server-4.2.asc"
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"
Expand Down
1 change: 1 addition & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mongodb_repository:
"3.6": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/3.6 main"
"4.0": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.0 main"
"4.2": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.2 main"
"4.4": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.4 main"

mongodb_pymongo_package: "{{ 'python3-pymongo' if ansible_facts['python'].version.major == 3 else 'python-pymongo' }}"
mongodb_pymongo_deps:
Expand Down
2 changes: 2 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ mongodb_repository:
"3.6": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/$basearch/"
"4.0": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/$basearch/"
"4.2": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/$basearch/"
"4.4": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/$basearch/"

mongodb_repository_gpgkey:
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
"4.2": "https://www.mongodb.org/static/pgp/server-4.2.asc"
"4.4": "https://www.mongodb.org/static/pgp/server-4.4.asc"

mongodb_pidfile_path: "{{ '/var/run/mongodb/mongod.pid' if ('mongodb-org' in mongodb_package) else '' }}"

Expand Down
1 change: 1 addition & 0 deletions vars/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mongodb_repository:
"3.6": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/3.6 multiverse"
"4.0": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/4.0 multiverse"
"4.2": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/4.2 multiverse"
"4.4": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/4.4 multiverse"

mongodb_pymongo_package: "{{ 'python3-pymongo' if ansible_facts['python'].version.major == 3 else 'python-pymongo' }}"
mongodb_pymongo_deps:
Expand Down

0 comments on commit 873fd19

Please sign in to comment.