From 52b1f395ea40d21ac102fcda73efc81aa34ae91f Mon Sep 17 00:00:00 2001 From: Daniel White Date: Sun, 8 May 2016 04:03:07 +1000 Subject: [PATCH 01/19] Ensure tests run with expected docker image This has been working so far since the tests have only cared about Ubuntu as a target. Now that RedHat is an option, the default needs to be overriden. --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 50b825c2..f9364176 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,10 +50,10 @@ before_install: script: # Test 1 - - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} + - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) @@ -63,11 +63,11 @@ script: # Test 2 - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) @@ -78,11 +78,11 @@ script: # Test 3 - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) @@ -93,12 +93,12 @@ script: # Test 4 - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' | grep -q 'changed=0.*failed=0' From b74bade421f0ef75658838ff1e0f6902090cfc5b Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 27 Apr 2016 14:45:25 +1000 Subject: [PATCH 02/19] 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. --- .travis.yml | 24 ++++++++++++ tasks/{install.deb.yml => install.debian.yml} | 2 - tasks/install.redhat.yml | 37 +++++++++++++++++++ tasks/main.yml | 9 ++++- templates/mongodb.repo.j2 | 8 ++++ vars/RedHat.yml | 9 +++++ 6 files changed, 85 insertions(+), 4 deletions(-) rename tasks/{install.deb.yml => install.debian.yml} (97%) create mode 100644 tasks/install.redhat.yml create mode 100644 templates/mongodb.repo.j2 create mode 100644 vars/RedHat.yml diff --git a/.travis.yml b/.travis.yml index f9364176..9cfcdb99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,30 @@ env: DISTRIBUTION=ubuntu-upstart DIST_VERSION=12.04 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 # version=12.04 diff --git a/tasks/install.deb.yml b/tasks/install.debian.yml similarity index 97% rename from tasks/install.deb.yml rename to tasks/install.debian.yml index fc7ed64f..461d4853 100644 --- a/tasks/install.deb.yml +++ b/tasks/install.debian.yml @@ -1,7 +1,5 @@ --- -- include_vars: "{{ansible_distribution}}.yml" - - name: Check if running on systemd command: cat /proc/1/cmdline register: systemd diff --git a/tasks/install.redhat.yml b/tasks/install.redhat.yml new file mode 100644 index 00000000..bb282236 --- /dev/null +++ b/tasks/install.redhat.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index aaf40857..ba8c75ee 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 - include: install.deb.yml - when: ansible_os_family == 'Debian' + include: "install.{{ ansible_os_family | lower }}.yml" tags: [mongodb] - name: Include configuration.yml diff --git a/templates/mongodb.repo.j2 b/templates/mongodb.repo.j2 new file mode 100644 index 00000000..1a284313 --- /dev/null +++ b/templates/mongodb.repo.j2 @@ -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 diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 00000000..0677b65f --- /dev/null +++ b/vars/RedHat.yml @@ -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" From 589222f25ebfbd7c1732b433ea1c18af377ec114 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 27 Apr 2016 14:51:53 +1000 Subject: [PATCH 03/19] Provide better default user for a RedHat based OS While we could define this in the per-platform variables, including this in the defaults maintains backwards compatability for users that want to override this value. --- README.md | 2 +- defaults/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9ca44b0..85c1091d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ mongodb_pymongo_from_pip: true # Install latest PyMongo via PI mongodb_user_update_password: "on_create" # MongoDB user password update default policy mongodb_manage_service: true -mongodb_user: mongodb +mongodb_user: "{{ 'mongod' if ('RedHat' == ansible_os_family) else 'mongodb' }}" mongodb_uid: mongodb_gid: mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}" diff --git a/defaults/main.yml b/defaults/main.yml index 515c2aab..59e7b5e2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,7 +10,7 @@ mongodb_force_wait_for_port: false mongodb_user_update_password: "on_create" # MongoDB user password update default policy mongodb_manage_service: true -mongodb_user: mongodb +mongodb_user: "{{ 'mongod' if ('RedHat' == ansible_os_family) else 'mongodb' }}" mongodb_uid: mongodb_gid: mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}" From 6ccd0a332ca7c6368b4d55324b5f50ccc46f15f6 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 27 Apr 2016 15:06:15 +1000 Subject: [PATCH 04/19] Indicate level of support for RHEL/CentOS Despite the test builds for CentOS, it's probably safe to mark them as unknown until they've been used a bit more heavily. --- README.md | 4 ++++ meta/main.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 85c1091d..51bb5e4d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ MongoDB support matrix: | Ubuntu 16.04 | :no_entry: | :x: | :x: | :x:| | Debian 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang:| | Debian 8.x | :no_entry: | :x: | :x: | :x:| +| CentOS 6.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | +| CentOS 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | +| RHEL 6.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | +| RHEL 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :white_check_mark: - fully tested, should work fine :interrobang: - will be added testing suite soon diff --git a/meta/main.yml b/meta/main.yml index 16fda1d6..c2eb4a45 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -16,6 +16,10 @@ galaxy_info: - name: Debian versions: - wheezy + - name: EL + versions: + - 6 + - 7 galaxy_tags: - database - database:nosql From 255dc39cc33072a805daf059d3efe6568bdc47de Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 27 Apr 2016 16:28:47 +1000 Subject: [PATCH 05/19] Define pidFilePath for offical RHEL packages The init script in these packages _assumes_ that this variable is defined. Without it, it fails to properly start the service. --- templates/mongod.conf.j2 | 3 +++ templates/mongod_init.conf.j2 | 3 +++ vars/RedHat.yml | 2 ++ 3 files changed, 8 insertions(+) diff --git a/templates/mongod.conf.j2 b/templates/mongod.conf.j2 index e5525153..3a073485 100644 --- a/templates/mongod.conf.j2 +++ b/templates/mongod.conf.j2 @@ -10,6 +10,9 @@ net: processManagement: fork: {{ mongodb_processmanagement_fork | to_nice_json}} + {% if mongodb_pidfile_path is defined and mongodb_pidfile_path != '' -%} + pidFilePath: {{ mongodb_pidfile_path }} + {% endif %} {% if mongodb_replication_replset -%} replication: diff --git a/templates/mongod_init.conf.j2 b/templates/mongod_init.conf.j2 index 5e31ce65..71bc4c10 100644 --- a/templates/mongod_init.conf.j2 +++ b/templates/mongod_init.conf.j2 @@ -10,6 +10,9 @@ net: processManagement: fork: {{ mongodb_processmanagement_fork | to_nice_json }} + {% if mongodb_pidfile_path is defined and mongodb_pidfile_path != '' -%} + pidFilePath: {{ mongodb_pidfile_path }} + {% endif %} security: authorization: 'disabled' diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 0677b65f..3697698b 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -7,3 +7,5 @@ mongodb_repository: mongodb_repository_gpgkey: "3.2": "https://www.mongodb.org/static/pgp/server-3.2.asc" + +mongodb_pidfile_path: "{{ '/var/run/mongodb/mongod.pid' if ('mongodb-org' in mongodb_package) else '' }}" From 4b22cc431de260a68b9d064c5911d31863bd74f7 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 27 Apr 2016 16:55:54 +1000 Subject: [PATCH 06/19] Enable server process forking by default on RedHat The init scripts that are provided assume that forking is enabled by default. This has been left in defaults, to preserve the capability for users to override this option. --- defaults/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 59e7b5e2..7bb64de1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -23,7 +23,9 @@ mongodb_net_maxconns: 65536 # Max number of simultaneous co mongodb_net_port: 27017 # Specify port number ## processManagement Options -mongodb_processmanagement_fork: false # Fork server process +# Fork server process +# Enabled by default for RedHat as the init scripts assume forking is enabled. +mongodb_processmanagement_fork: "{{ 'RedHat' == ansible_os_family }}" ## security Options # Disable or enable security. Possible values: 'disabled', 'enabled' From 01bdfc6ef4b72f6461d500373bebe79bec32469c Mon Sep 17 00:00:00 2001 From: jsaliba Date: Wed, 13 Sep 2017 16:30:16 +0200 Subject: [PATCH 07/19] Missed conflict. --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 476e2e64..33ee17f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,21 +77,12 @@ before_install: script: # Test 1 -<<<<<<< HEAD - - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} - # Idempotence test - > sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} - | grep -q 'changed=0.*failed=0' -======= - - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} - -e image_name=${DISTRIBUTION}:${DIST_VERSION} # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} - -e image_name=${DISTRIBUTION}:${DIST_VERSION} | grep -q 'changed=0.*failed=0' ->>>>>>> 9ba2bbc86a637ae1250cab42ce4f1192f6979fb6 + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} + | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) From d6997059cbb9f4797b7321be352d715d4254d210 Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 08:55:31 +0200 Subject: [PATCH 08/19] Added support for mongo 3.4 when executing against RedHat --- .travis.yml | 4 ++++ vars/RedHat.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 33ee17f8..f673494b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,10 @@ env: DISTRIBUTION=centos DIST_VERSION=7 MONGODB_VERSION=3.2 + - > + DISTRIBUTION=centos + DIST_VERSION=7 + MONGODB_VERSION=3.4 # - > # distribution=ubuntu-upstart # version=12.04 diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 3697698b..f61e2dfb 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -4,8 +4,10 @@ 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/" + "3.4": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/$basearch/" mongodb_repository_gpgkey: "3.2": "https://www.mongodb.org/static/pgp/server-3.2.asc" + "3.4": "https://www.mongodb.org/static/pgp/server-3.4.asc" mongodb_pidfile_path: "{{ '/var/run/mongodb/mongod.pid' if ('mongodb-org' in mongodb_package) else '' }}" From 429e10855115e9004c6f01bd1a1889b749531ede Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 08:57:16 +0200 Subject: [PATCH 09/19] Trying to get Docker tests to work by running tests in privileged containers and installing EPEL repository for CentOS image. --- tasks/install.redhat.yml | 20 ++++++++++++++++++++ tests/site.yml | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tasks/install.redhat.yml b/tasks/install.redhat.yml index bb282236..725484ce 100644 --- a/tasks/install.redhat.yml +++ b/tasks/install.redhat.yml @@ -1,5 +1,9 @@ --- +- name: Establish some role-related facts + set_fact: + mongodb_major_version: "{{ mongodb_version[0:3] }}" + - name: Add YUM repository template: src: mongodb.repo.j2 @@ -16,12 +20,28 @@ - "{{ mongodb_package }}" - numactl +# This step is needed when running CentOS in Docker since the docker image does not come with EPEL installed by default +- name: Install EPEL release + yum: + name: epel-release + state: present + - name: Install PyMongo package yum: name: python-pymongo state: latest when: not mongodb_pymongo_from_pip +# - name: Install python-devel +# yum: +# name: "python-devel" +# when: mongodb_pymongo_from_pip + +# - name: Install PIP +# yum: +# name: "python-pip" +# when: mongodb_pymongo_from_pip + - name: Install PIP yum: name: "{{ item }}" diff --git a/tests/site.yml b/tests/site.yml index 1ab41628..ff456d29 100644 --- a/tests/site.yml +++ b/tests/site.yml @@ -11,11 +11,12 @@ image: "{{ image_name }}" command: "/sbin/init" state: started + privileged: true with_items: - mongo1 - mongo2 - mongo3 - + - hosts: "{{ target }}" become: no gather_facts: yes From 84ecb5707e3a882dc8f63f553d80809b76ea9228 Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 08:59:49 +0200 Subject: [PATCH 10/19] Disable every test except for CentOS 7 and Mongo 3.4 --- .travis.yml | 96 ++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/.travis.yml b/.travis.yml index f673494b..660be23e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,54 +3,54 @@ sudo: required env: - - > - DISTRIBUTION=ubuntu-upstart - DIST_VERSION=14.04 - MONGODB_VERSION=3.2 - - > - DISTRIBUTION=ubuntu-upstart - DIST_VERSION=14.04 - MONGODB_VERSION=3.0 - - > - DISTRIBUTION=ubuntu-upstart - DIST_VERSION=14.04 - MONGODB_VERSION=2.6 - - > - DISTRIBUTION=ubuntu-upstart - DIST_VERSION=12.04-builded - MONGODB_VERSION=3.2 - - > - DISTRIBUTION=ubuntu-upstart - DIST_VERSION=12.04-builded - MONGODB_VERSION=3.0 - - > - DISTRIBUTION=ubuntu-upstart - DIST_VERSION=12.04-builded - 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 + # DIST_VERSION=14.04 + # MONGODB_VERSION=3.2 + # - > + # DISTRIBUTION=ubuntu-upstart + # DIST_VERSION=14.04 + # MONGODB_VERSION=3.0 + # - > + # DISTRIBUTION=ubuntu-upstart + # DIST_VERSION=14.04 + # MONGODB_VERSION=2.6 + # - > + # DISTRIBUTION=ubuntu-upstart + # DIST_VERSION=12.04-builded + # MONGODB_VERSION=3.2 + # - > + # DISTRIBUTION=ubuntu-upstart + # DIST_VERSION=12.04-builded + # MONGODB_VERSION=3.0 + # - > + # DISTRIBUTION=ubuntu-upstart + # DIST_VERSION=12.04-builded + # 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=centos DIST_VERSION=7 From 9bb46f2f2038bd1ce71dac332c7c4dab63b6b1f7 Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 09:47:27 +0200 Subject: [PATCH 11/19] CentOS 7 docker file --- .gitignore | 3 ++- tasks/install.redhat.yml | 10 ---------- tasks/main.yml | 2 +- tests/Dockerfile.centos_7-builded | 10 ++++++++++ tests/site.yml | 4 ++++ 5 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 tests/Dockerfile.centos_7-builded diff --git a/.gitignore b/.gitignore index f57a070f..a1d8754d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ +tests/*.retry *~ \#*\# .\#* -/.python-version \ No newline at end of file +/.python-version diff --git a/tasks/install.redhat.yml b/tasks/install.redhat.yml index 725484ce..d265621f 100644 --- a/tasks/install.redhat.yml +++ b/tasks/install.redhat.yml @@ -32,16 +32,6 @@ state: latest when: not mongodb_pymongo_from_pip -# - name: Install python-devel -# yum: -# name: "python-devel" -# when: mongodb_pymongo_from_pip - -# - name: Install PIP -# yum: -# name: "python-pip" -# when: mongodb_pymongo_from_pip - - name: Install PIP yum: name: "{{ item }}" diff --git a/tasks/main.yml b/tasks/main.yml index d686682e..aa5eda69 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,7 +39,7 @@ when: ( mongodb_security_authorization == 'enabled' and (not mongodb_replication_replset or mongodb_replication_replset == '') ) - no_log: true + # no_log: true tags: [mongodb] - name: Include authorization configuration diff --git a/tests/Dockerfile.centos_7-builded b/tests/Dockerfile.centos_7-builded new file mode 100644 index 00000000..19ba8497 --- /dev/null +++ b/tests/Dockerfile.centos_7-builded @@ -0,0 +1,10 @@ +FROM centos:7 + +# This is needed so that ansible managed to read "ansible_default_ipv4" +RUN yum install iproute + +# we can has SSH +EXPOSE 22 + +# pepare for takeoff +CMD ["/usr/sbin/init"] \ No newline at end of file diff --git a/tests/site.yml b/tests/site.yml index ff456d29..b6934dc4 100644 --- a/tests/site.yml +++ b/tests/site.yml @@ -20,6 +20,10 @@ - hosts: "{{ target }}" become: no gather_facts: yes + pre_tasks: + - name: Show hostvars + debug: + var: "hostvars[inventory_hostname]['ansible_default_ipv4']" roles: - role: greendayonfire.mongodb when: "'mongo_master' in group_names" From 986678b733c0525d0f5017746453c9331f66e4ad Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 10:56:34 +0200 Subject: [PATCH 12/19] Moved EPEL installation command to Docker file. Travis now uses custom Docker image built from CentOS Dockerfile. nolog re-enabled for user admin checking. --- .travis.yml | 2 +- tasks/install.redhat.yml | 6 ------ tasks/main.yml | 5 ++--- tests/Dockerfile.centos_7-builded | 7 +++++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 660be23e..6a81584d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ env: # MONGODB_VERSION=3.2 - > DISTRIBUTION=centos - DIST_VERSION=7 + DIST_VERSION=7-builded MONGODB_VERSION=3.4 # - > # distribution=ubuntu-upstart diff --git a/tasks/install.redhat.yml b/tasks/install.redhat.yml index d265621f..afa02293 100644 --- a/tasks/install.redhat.yml +++ b/tasks/install.redhat.yml @@ -20,12 +20,6 @@ - "{{ mongodb_package }}" - numactl -# This step is needed when running CentOS in Docker since the docker image does not come with EPEL installed by default -- name: Install EPEL release - yum: - name: epel-release - state: present - - name: Install PyMongo package yum: name: python-pymongo diff --git a/tasks/main.yml b/tasks/main.yml index aa5eda69..94d11211 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -27,11 +27,10 @@ when: mongodb_replication_replset and mongodb_replication_replset != '' tags: [mongodb] -- name: Check user admin is exists +- name: Check where admin user already exists command: > mongo --quiet -u {{ mongodb_user_admin_name }} \ -p {{ mongodb_user_admin_password }} --port {{ mongodb_net_port }} --eval 'db.version()' admin - register: mongodb_user_admin_check changed_when: false always_run: yes # side-effect free, so it can be run in check-mode as well @@ -39,7 +38,7 @@ when: ( mongodb_security_authorization == 'enabled' and (not mongodb_replication_replset or mongodb_replication_replset == '') ) - # no_log: true + no_log: true tags: [mongodb] - name: Include authorization configuration diff --git a/tests/Dockerfile.centos_7-builded b/tests/Dockerfile.centos_7-builded index 19ba8497..d86860a9 100644 --- a/tests/Dockerfile.centos_7-builded +++ b/tests/Dockerfile.centos_7-builded @@ -1,10 +1,13 @@ FROM centos:7 # This is needed so that ansible managed to read "ansible_default_ipv4" -RUN yum install iproute +RUN yum install iproute -y + +# This step is needed since standard CentOS docker image does not come with EPEL installed by default +RUN yum install epel-release # we can has SSH EXPOSE 22 # pepare for takeoff -CMD ["/usr/sbin/init"] \ No newline at end of file +CMD ["/usr/sbin/init"] From 2e6cd41cb13f0a9fd0419743483326ea6070113c Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 10:59:59 +0200 Subject: [PATCH 13/19] yum -y flag for epel release in dockerfile. --- tests/Dockerfile.centos_7-builded | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Dockerfile.centos_7-builded b/tests/Dockerfile.centos_7-builded index d86860a9..55da0ca8 100644 --- a/tests/Dockerfile.centos_7-builded +++ b/tests/Dockerfile.centos_7-builded @@ -4,7 +4,7 @@ FROM centos:7 RUN yum install iproute -y # This step is needed since standard CentOS docker image does not come with EPEL installed by default -RUN yum install epel-release +RUN yum install epel-release -y # we can has SSH EXPOSE 22 From 61ccb2f46b347cef00c37c019effebd57ead6a93 Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 11:21:37 +0200 Subject: [PATCH 14/19] renabled rest of tests. --- .travis.yml | 100 ++++++++++++++++-------------- tests/Dockerfile.centos_6-builded | 13 ++++ tests/site.yml | 5 +- 3 files changed, 66 insertions(+), 52 deletions(-) create mode 100644 tests/Dockerfile.centos_6-builded diff --git a/.travis.yml b/.travis.yml index 6a81584d..2b0603eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,54 +3,58 @@ sudo: required env: - # - > - # DISTRIBUTION=ubuntu-upstart - # DIST_VERSION=14.04 - # MONGODB_VERSION=3.2 - # - > - # DISTRIBUTION=ubuntu-upstart - # DIST_VERSION=14.04 - # MONGODB_VERSION=3.0 - # - > - # DISTRIBUTION=ubuntu-upstart - # DIST_VERSION=14.04 - # MONGODB_VERSION=2.6 - # - > - # DISTRIBUTION=ubuntu-upstart - # DIST_VERSION=12.04-builded - # MONGODB_VERSION=3.2 - # - > - # DISTRIBUTION=ubuntu-upstart - # DIST_VERSION=12.04-builded - # MONGODB_VERSION=3.0 - # - > - # DISTRIBUTION=ubuntu-upstart - # DIST_VERSION=12.04-builded - # 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 + DIST_VERSION=14.04 + MONGODB_VERSION=3.2 + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=14.04 + MONGODB_VERSION=3.0 + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=14.04 + MONGODB_VERSION=2.6 + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=12.04-builded + MONGODB_VERSION=3.2 + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=12.04-builded + MONGODB_VERSION=3.0 + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=12.04-builded + MONGODB_VERSION=2.6 + - > + DISTRIBUTION=centos + DIST_VERSION=6-builded + MONGODB_VERSION=2.6 + - > + DISTRIBUTION=centos + DIST_VERSION=6-builded + MONGODB_VERSION=3.0 + - > + DISTRIBUTION=centos + DIST_VERSION=6-builded + MONGODB_VERSION=3.2 + - > + DISTRIBUTION=centos + DIST_VERSION=6-builded + MONGODB_VERSION=3.4 + - > + DISTRIBUTION=centos + DIST_VERSION=7-builded + MONGODB_VERSION=2.6 + - > + DISTRIBUTION=centos + DIST_VERSION=7-builded + MONGODB_VERSION=3.0 + - > + DISTRIBUTION=centos + DIST_VERSION=7-builded + MONGODB_VERSION=3.2 - > DISTRIBUTION=centos DIST_VERSION=7-builded diff --git a/tests/Dockerfile.centos_6-builded b/tests/Dockerfile.centos_6-builded new file mode 100644 index 00000000..06fb3b38 --- /dev/null +++ b/tests/Dockerfile.centos_6-builded @@ -0,0 +1,13 @@ +FROM centos:6 + +# This is needed so that ansible managed to read "ansible_default_ipv4" +RUN yum install iproute -y + +# This step is needed since standard CentOS docker image does not come with EPEL installed by default +RUN yum install epel-release -y + +# we can has SSH +EXPOSE 22 + +# pepare for takeoff +CMD ["/usr/sbin/init"] diff --git a/tests/site.yml b/tests/site.yml index b6934dc4..f6d861f9 100644 --- a/tests/site.yml +++ b/tests/site.yml @@ -20,10 +20,7 @@ - hosts: "{{ target }}" become: no gather_facts: yes - pre_tasks: - - name: Show hostvars - debug: - var: "hostvars[inventory_hostname]['ansible_default_ipv4']" + roles: - role: greendayonfire.mongodb when: "'mongo_master' in group_names" From 6d529d5238f1adcb83b00ac83d37f1ac6dc4872b Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 13:14:50 +0200 Subject: [PATCH 15/19] Added initscripts to dockerfile --- tests/Dockerfile.centos_7-builded | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Dockerfile.centos_7-builded b/tests/Dockerfile.centos_7-builded index 55da0ca8..671e8e35 100644 --- a/tests/Dockerfile.centos_7-builded +++ b/tests/Dockerfile.centos_7-builded @@ -6,6 +6,10 @@ RUN yum install iproute -y # This step is needed since standard CentOS docker image does not come with EPEL installed by default RUN yum install epel-release -y +# This step is needed since standard CentOS docker image does not come with init-functions installed by default. +# This package seems to be required for Mongo 3.2 and downwards +RUN yum install initscripts -y + # we can has SSH EXPOSE 22 From 349383f1fd8aa999b351e994290d65033409e88b Mon Sep 17 00:00:00 2001 From: jsaliba Date: Thu, 14 Sep 2017 14:21:36 +0200 Subject: [PATCH 16/19] fixed readme interrobang --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b7f02b65..7d5b5699 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ MongoDB support matrix: | Ubuntu 16.04 | :no_entry: | :x: | :x: | :x:| :x:| | Debian 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang:| :x:| | Debian 8.x | :no_entry: | :x: | :x: | :x:| :x:| -| RHEL 6.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang | -| RHEL 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang | +| RHEL 6.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: | +| RHEL 7.x | :no_entry: | :interrobang: | :interrobang: | :interrobang: | :interrobang: | :white_check_mark: - fully tested, should work fine :interrobang: - will be added testing suite soon From 5b3623f9f1328eb30d0a93e66cae7761621bedb5 Mon Sep 17 00:00:00 2001 From: jsaliba Date: Mon, 18 Sep 2017 12:36:33 +0200 Subject: [PATCH 17/19] MMS Agent can now be installed on RHEL distributions. --- tasks/mms-agent.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tasks/mms-agent.yml b/tasks/mms-agent.yml index c8658e12..f2d8fc24 100644 --- a/tasks/mms-agent.yml +++ b/tasks/mms-agent.yml @@ -1,12 +1,25 @@ --- -- name: Install MMS agent pt. 1 +- name: Download MMS Agent (Debian) get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.deb register: mongodb_mms_agent_loaded + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' -- name: Install MMS agent pt. 2 - apt: deb={{mongodb_storage_dbpath}}/mms-agent.deb - when: mongodb_mms_agent_loaded.changed +- name: Download MMS Agent (RHEL) + get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.rpm + register: mongodb_mms_agent_loaded + when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' + +- name: Install MMS agent (Debian) + apt: + deb: "{{mongodb_storage_dbpath}}/mms-agent.deb" + when: mongodb_mms_agent_loaded.changed and (ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu') + +- name: Install MMS agent (RHEL) + yum: + name: "{{mongodb_storage_dbpath}}/mms-agent.rpm" + state: present + when: mongodb_mms_agent_loaded.changed and (ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux') - name: Configure the MMS agent pt. 1 file: state=directory path=/etc/mongodb-mms owner={{mongodb_user}} group={{mongodb_user}} mode=0755 From b0a9f34baeeaecaf26fd09292fedda2da3bd6ed8 Mon Sep 17 00:00:00 2001 From: jsaliba Date: Mon, 18 Sep 2017 12:39:07 +0200 Subject: [PATCH 18/19] Installation of EPEL repository is now part of RHEL YML file. --- tasks/install.redhat.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks/install.redhat.yml b/tasks/install.redhat.yml index afa02293..668a0de3 100644 --- a/tasks/install.redhat.yml +++ b/tasks/install.redhat.yml @@ -4,6 +4,11 @@ set_fact: mongodb_major_version: "{{ mongodb_version[0:3] }}" +- name: Install EPEL release repository + package: + name: epel-release + state: present + - name: Add YUM repository template: src: mongodb.repo.j2 From 7c3cfd2353dfb28751030f62b0c456263b2cb07a Mon Sep 17 00:00:00 2001 From: jsaliba Date: Mon, 18 Sep 2017 12:41:09 +0200 Subject: [PATCH 19/19] Added tests for Mongo 3.4 against Ubuntu 14.04 and 12.04 --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2b0603eb..e5dfc26a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,10 @@ sudo: required env: + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=14.04 + MONGODB_VERSION=3.4 - > DISTRIBUTION=ubuntu-upstart DIST_VERSION=14.04 @@ -15,6 +19,10 @@ env: DISTRIBUTION=ubuntu-upstart DIST_VERSION=14.04 MONGODB_VERSION=2.6 + - > + DISTRIBUTION=ubuntu-upstart + DIST_VERSION=12.04-builded + MONGODB_VERSION=3.4 - > DISTRIBUTION=ubuntu-upstart DIST_VERSION=12.04-builded @@ -82,7 +90,7 @@ before_install: sudo docker build --rm=true --file=tests/Dockerfile.${DISTRIBUTION}_${DIST_VERSION} --tag ${DISTRIBUTION}:${DIST_VERSION} tests; else sudo docker pull ${DISTRIBUTION}:${DIST_VERSION}; fi - sudo ln -s ${PWD} /etc/ansible/roles/greendayonfire.mongodb - + script: # Test 1 - >