diff --git a/.github/workflows/amazonlinux2.yml b/.github/workflows/amazonlinux2.yml index 7231fab2..d9ba898b 100644 --- a/.github/workflows/amazonlinux2.yml +++ b/.github/workflows/amazonlinux2.yml @@ -16,6 +16,7 @@ jobs: molecule_distro: - amazonlinux2 mongodb_version: + - '4.4' - '4.2' - '4.0' - '3.6' diff --git a/.github/workflows/centos.yml b/.github/workflows/centos.yml index 4f6d8a7b..b19e1532 100644 --- a/.github/workflows/centos.yml +++ b/.github/workflows/centos.yml @@ -17,6 +17,7 @@ jobs: - centos7 - centos8 mongodb_version: + - '4.4' - '4.2' - '4.0' - '3.6' diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index 5cef742d..dd73b098 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -17,6 +17,7 @@ jobs: - debian9 - debian10 mongodb_version: + - '4.4' - '4.2' - '4.0' - '3.6' diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index a1ce6a2f..3426359c 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -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 }} diff --git a/README.md b/README.md index 3130499d..ee0313fe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml index 50281924..26caacd7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/molecule/cluster/molecule.yml b/molecule/cluster/molecule.yml index 943b98b9..e8f41b3b 100644 --- a/molecule/cluster/molecule.yml +++ b/molecule/cluster/molecule.yml @@ -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} diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 08b28235..dc9134b5 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -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: diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 57450273..cb516596 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -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: diff --git a/tasks/install.debian.yml b/tasks/install.debian.yml index d6fcde0c..adfa8130 100644 --- a/tasks/install.debian.yml +++ b/tasks/install.debian.yml @@ -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)) @@ -38,10 +38,9 @@ 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 @@ -49,7 +48,7 @@ - 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: @@ -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: diff --git a/tasks/main.yml b/tasks/main.yml index 1e72f397..9659be9d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/vars/Amazon.yml b/vars/Amazon.yml index d7789d1a..9bb80478 100644 --- a/vars/Amazon.yml +++ b/vars/Amazon.yml @@ -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" diff --git a/vars/Debian.yml b/vars/Debian.yml index 6a63d719..8871afc8 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -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: diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 7e55f48d..34792f99 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -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 '' }}" diff --git a/vars/Ubuntu.yml b/vars/Ubuntu.yml index 11578211..5fd8dd19 100644 --- a/vars/Ubuntu.yml +++ b/vars/Ubuntu.yml @@ -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: