summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnsible Core Team <info@ansible.com>2020-03-09 09:40:30 +0000
committerAnsible Core Team <info@ansible.com>2020-03-09 09:40:30 +0000
commiteec0fb31de7c73c8556638a249789b6b0d7e7956 (patch)
tree2f1c62cca7249d591b701a0965d45618fb9919d8 /test
parentef24d794eedb4b947bcbaa2681c7fc9cdfe8ff23 (diff)
downloadansible-eec0fb31de7c73c8556638a249789b6b0d7e7956.tar.gz
Migrated to community.mongo
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/mongodb_info/aliases5
-rw-r--r--test/integration/targets/mongodb_info/defaults/main.yml4
-rw-r--r--test/integration/targets/mongodb_info/meta/main.yml3
-rw-r--r--test/integration/targets/mongodb_info/tasks/main.yml8
-rw-r--r--test/integration/targets/mongodb_info/tasks/mongodb_info.yml60
-rw-r--r--test/integration/targets/mongodb_parameter/aliases7
-rw-r--r--test/integration/targets/mongodb_parameter/defaults/main.yml21
-rw-r--r--test/integration/targets/mongodb_parameter/meta/main.yml3
-rw-r--r--test/integration/targets/mongodb_parameter/tasks/main.yml143
-rw-r--r--test/integration/targets/mongodb_parameter/tasks/mongod_singlenode.yml55
-rw-r--r--test/integration/targets/mongodb_parameter/tasks/mongod_teardown.yml25
-rw-r--r--test/integration/targets/mongodb_replicaset/aliases7
-rw-r--r--test/integration/targets/mongodb_replicaset/defaults/main.yml24
-rw-r--r--test/integration/targets/mongodb_replicaset/files/js/is_primary.js13
-rw-r--r--test/integration/targets/mongodb_replicaset/meta/main.yml3
-rw-r--r--test/integration/targets/mongodb_replicaset/tasks/main.yml540
-rw-r--r--test/integration/targets/mongodb_replicaset/tasks/mongod_replicaset.yml43
-rw-r--r--test/integration/targets/mongodb_replicaset/tasks/mongod_teardown.yml27
-rw-r--r--test/integration/targets/mongodb_shard/aliases7
-rw-r--r--test/integration/targets/mongodb_shard/defaults/main.yml16
-rw-r--r--test/integration/targets/mongodb_shard/files/bash/ensure_primary.sh.j238
-rw-r--r--test/integration/targets/mongodb_shard/files/js/is_primary.js13
-rw-r--r--test/integration/targets/mongodb_shard/meta/main.yml3
-rw-r--r--test/integration/targets/mongodb_shard/tasks/main.yml458
-rw-r--r--test/integration/targets/mongodb_shard/tasks/mongod_replicaset.yml51
-rw-r--r--test/integration/targets/mongodb_shard/tasks/mongod_teardown.yml35
-rw-r--r--test/integration/targets/mongodb_shard/templates/create_user_root_3.2.js.j28
-rw-r--r--test/integration/targets/mongodb_user/aliases8
-rw-r--r--test/integration/targets/mongodb_user/defaults/main.yml21
-rw-r--r--test/integration/targets/mongodb_user/files/js/is_primary.js13
-rw-r--r--test/integration/targets/mongodb_user/meta/main.yml3
-rw-r--r--test/integration/targets/mongodb_user/tasks/main.yml226
-rw-r--r--test/integration/targets/mongodb_user/tasks/mongod_replicaset.yml51
-rw-r--r--test/integration/targets/mongodb_user/tasks/mongod_teardown.yml27
-rw-r--r--test/sanity/ignore.txt4
35 files changed, 0 insertions, 1973 deletions
diff --git a/test/integration/targets/mongodb_info/aliases b/test/integration/targets/mongodb_info/aliases
deleted file mode 100644
index f2df32c48a..0000000000
--- a/test/integration/targets/mongodb_info/aliases
+++ /dev/null
@@ -1,5 +0,0 @@
-destructive
-shippable/posix/group4
-skip/aix
-skip/osx
-skip/freebsd
diff --git a/test/integration/targets/mongodb_info/defaults/main.yml b/test/integration/targets/mongodb_info/defaults/main.yml
deleted file mode 100644
index 5f41a8becf..0000000000
--- a/test/integration/targets/mongodb_info/defaults/main.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-mongodb_default_port: 27017
-mongodb_admin_user: admin
-mongodb_admin_password: admin
-mongodb_default_db: admin
diff --git a/test/integration/targets/mongodb_info/meta/main.yml b/test/integration/targets/mongodb_info/meta/main.yml
deleted file mode 100644
index 31081e2ede..0000000000
--- a/test/integration/targets/mongodb_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
-- setup_mongodb_v4
-- setup_remote_tmp_dir
diff --git a/test/integration/targets/mongodb_info/tasks/main.yml b/test/integration/targets/mongodb_info/tasks/main.yml
deleted file mode 100644
index 859d4a66ae..0000000000
--- a/test/integration/targets/mongodb_info/tasks/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2020, Andrew Klychkov <aaklychkov@mail.ru>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-# Main mongodb_info module tests
-- import_tasks: mongodb_info.yml
- when:
- - ansible_distribution == 'CentOS'
- - ansible_distribution_major_version is version('7', '>=')
diff --git a/test/integration/targets/mongodb_info/tasks/mongodb_info.yml b/test/integration/targets/mongodb_info/tasks/mongodb_info.yml
deleted file mode 100644
index 3690622475..0000000000
--- a/test/integration/targets/mongodb_info/tasks/mongodb_info.yml
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2020, Andrew Klychkov <aaklychkov@mail.ru>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-- vars:
- task_parameters: &task_parameters
- register: result
- mongo_parameters: &mongo_parameters
- login_port: '{{ mongodb_default_port }}'
- login_user: '{{ mongodb_admin_user }}'
- login_password: '{{ mongodb_admin_password }}'
- login_database: '{{ mongodb_default_db }}'
-
- block:
-
- - name: Get info
- <<: *task_parameters
- mongodb_info:
- <<: *mongo_parameters
-
- - assert:
- that:
- - result is not changed
- - result.general.version == '4.2.3'
- - result.databases.admin
- - result.total_size
- - result.users.admin
- - result.roles.backup
- - result.parameters.logLevel == 0
-
- - name: Get info with filter
- <<: *task_parameters
- mongodb_info:
- <<: *mongo_parameters
- filter: general, total_size
-
- - assert:
- that:
- - result is not changed
- - result.general.version == '4.2.3'
- - result.total_size
- - result.databases is not defined
- - result.parameters is not defined
- - result.users is not defined
- - result.roles is not defined
-
- - name: Get info with filter
- <<: *task_parameters
- mongodb_info:
- <<: *mongo_parameters
- filter: '!parameters'
-
- - assert:
- that:
- - result is not changed
- - result.general.version == '4.2.3'
- - result.databases.admin
- - result.total_size
- - result.users.admin
- - result.roles.backup
- - result.parameters is not defined
diff --git a/test/integration/targets/mongodb_parameter/aliases b/test/integration/targets/mongodb_parameter/aliases
deleted file mode 100644
index 8251a83e7f..0000000000
--- a/test/integration/targets/mongodb_parameter/aliases
+++ /dev/null
@@ -1,7 +0,0 @@
-destructive
-shippable/posix/group1
-skip/aix
-skip/osx
-skip/freebsd
-skip/rhel
-needs/root
diff --git a/test/integration/targets/mongodb_parameter/defaults/main.yml b/test/integration/targets/mongodb_parameter/defaults/main.yml
deleted file mode 100644
index aac55526df..0000000000
--- a/test/integration/targets/mongodb_parameter/defaults/main.yml
+++ /dev/null
@@ -1,21 +0,0 @@
----
-# defaults file for test_mongodb_user
-mongodb_admin_user: test_root
-mongodb_admin_password: saE_Rr9!gE6gh#e~R#nZ
-mongod_auth: false
-kill_signal: SIGTERM
-# Should be one of
-# --storageEngine wiredTiger --wiredTigerEngineConfigString="cache_size=200M"
-# --storageEngine mmapv1 --nojournal
-mongod_storage_engine_opts: "--storageEngine wiredTiger --wiredTigerEngineConfigString='cache_size=200M'"
-mongodb_user: mongodb
-mongodb_user_list:
- - { "name": "user1", "password": "password1", "roles": "read", "database": "test" }
- - { "name": "user2", "password": "password2", "roles": "readWrite", "database": "test" }
- - { "name": "user3", "password": "password3", "roles": "dbAdmin", "database": "test" }
- - { "name": "user4", "password": "password4", "roles": "userAdmin", "database": "test" }
- - { "name": "user5", "password": "password5", "roles": "clusterAdmin", "database": "admin" }
- - { "name": "user6", "password": "password6", "roles": "readAnyDatabase", "database": "admin" }
- - { "name": "user7", "password": "password7", "roles": "readWriteAnyDatabase", "database": "admin" }
- - { "name": "user8", "password": "password8", "roles": "userAdminAnyDatabase", "database": "admin" }
- - { "name": "user9", "password": "password9", "roles": "dbAdminAnyDatabase", "database": "admin" }
diff --git a/test/integration/targets/mongodb_parameter/meta/main.yml b/test/integration/targets/mongodb_parameter/meta/main.yml
deleted file mode 100644
index 9d941be0bc..0000000000
--- a/test/integration/targets/mongodb_parameter/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
- - setup_mongodb
- - setup_remote_tmp_dir
diff --git a/test/integration/targets/mongodb_parameter/tasks/main.yml b/test/integration/targets/mongodb_parameter/tasks/main.yml
deleted file mode 100644
index a0fda1dc60..0000000000
--- a/test/integration/targets/mongodb_parameter/tasks/main.yml
+++ /dev/null
@@ -1,143 +0,0 @@
-# test code for the mongodb_parameter module
-# (c) 2019, Rhys Campbell <rhys.james.campbell@googlemail.com>
-
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# ============================================================
-
-- name: Ensure tests home exists
- file:
- path: "{{ remote_tmp_dir }}/tests"
- state: directory
-
-- include_tasks: mongod_teardown.yml
-
-- include_tasks: mongod_singlenode.yml
-
-- name: Set syncdelay to 99
- mongodb_parameter:
- login_port: 3001
- param: syncdelay
- value: 99
- param_type: int
- register: sd_change
-
-- assert:
- that:
- - sd_change.before | int == 60
- - sd_change.after | int == 99
- - sd_change.changed == True
-
-- name: Set syncdelay to 99 (again)
- mongodb_parameter:
- login_port: 3001
- param: syncdelay
- value: 99
- param_type: int
- register: sd_change
-
-- assert:
- that:
- - sd_change.before | int == 99
- - sd_change.after | int == 99
- - sd_change.changed == False
-
-- name: Create admin user with module
- mongodb_user:
- login_port: 3001
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: root
- state: present
- register: mongodb_admin_user_created
-
-- assert:
- that:
- - mongodb_admin_user_created.changed == True
-
-- name: Kill all mongod processes
- command: pkill -{{ kill_signal }} mongod
- ignore_errors: true
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- delay: 3
- with_items: "{{ pids_of_mongod }}"
-
-- set_fact:
- mongod_auth: true
-
-- include_tasks: mongod_singlenode.yml
-# Tests with auth enabled
-
-- name: Set syncdelay to 59 with auth
- mongodb_parameter:
- login_port: 3001
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- param: syncdelay
- value: 59
- param_type: int
- register: sd_change
-
-- assert:
- that:
- - sd_change.before | int == 60
- - sd_change.after | int == 59
- - sd_change.changed == True
-
-- name: Set syncdelay to 59 (again) with auth
- mongodb_parameter:
- login_port: 3001
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- param: syncdelay
- value: 59
- param_type: int
- register: sd_change
-
-- assert:
- that:
- - sd_change.before | int == 59
- - sd_change.after | int == 59
- - sd_change.changed == False
-
-- name: Set authenticationMechanisms to MONGODB-X509 with auth (will fail)
- mongodb_parameter:
- login_port: 3001
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- param: authenticationMechanisms
- value: "MONGODB-X509"
- param_type: str
- register: diag_change
- ignore_errors: yes
-
-- assert:
- that:
- - '"unable to change parameter" in diag_change.msg'
- - diag_change.failed == True
-
-# Clean up
-- include_tasks: mongod_teardown.yml
diff --git a/test/integration/targets/mongodb_parameter/tasks/mongod_singlenode.yml b/test/integration/targets/mongodb_parameter/tasks/mongod_singlenode.yml
deleted file mode 100644
index 291cb1c980..0000000000
--- a/test/integration/targets/mongodb_parameter/tasks/mongod_singlenode.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-- name: Set mongodb_user user for redhat
- set_fact:
- mongodb_user: "mongod"
- when: ansible_os_family == "RedHat"
-
-- set_fact:
- mongodb_nodes:
- - 3001
-
-- name: Create directories for mongod processes
- file:
- path: "{{ remote_tmp_dir }}/mongod{{ item }}"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
- recurse: yes
- with_items: "{{ mongodb_nodes }}"
-
-- name: Ensure {{ remote_tmp_dir }}/config dir exists
- file:
- path: "{{ remote_tmp_dir }}/config"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
-
-- name: Create keyfile
- copy:
- dest: "{{ remote_tmp_dir }}/my.key"
- content: |
- fd2CUrbXBJpB4rt74A6F
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0600
- when: mongod_auth == True
-
-- name: Spawn mongod process without auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --logpath mongod{{ item }}/log.log --fork
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == False
-
-- name: Spawn mongod process with auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --logpath mongod{{ item }}/log.log --fork --auth --keyFile my.key
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == True
-
-- name: Wait for mongod to start responding
- wait_for:
- port: "{{ item }}"
- with_items: "{{ mongodb_nodes }}"
diff --git a/test/integration/targets/mongodb_parameter/tasks/mongod_teardown.yml b/test/integration/targets/mongodb_parameter/tasks/mongod_teardown.yml
deleted file mode 100644
index a904a718b2..0000000000
--- a/test/integration/targets/mongodb_parameter/tasks/mongod_teardown.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-- name: Kill all mongod processes
- command: pkill -{{ kill_signal }} mongod
- ignore_errors: true
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- delay: 1
- with_items: "{{ pids_of_mongod }}"
-
-- name: Remove all mongod folders
- file:
- path: "{{ remote_tmp_dir }}/{{ item }}"
- state: absent
- with_items:
- - mongod3001
-
-- name: Remove all mongod sock files
- shell: rm -Rf /tmp/mongodb*.sock
diff --git a/test/integration/targets/mongodb_replicaset/aliases b/test/integration/targets/mongodb_replicaset/aliases
deleted file mode 100644
index 8251a83e7f..0000000000
--- a/test/integration/targets/mongodb_replicaset/aliases
+++ /dev/null
@@ -1,7 +0,0 @@
-destructive
-shippable/posix/group1
-skip/aix
-skip/osx
-skip/freebsd
-skip/rhel
-needs/root
diff --git a/test/integration/targets/mongodb_replicaset/defaults/main.yml b/test/integration/targets/mongodb_replicaset/defaults/main.yml
deleted file mode 100644
index 343d48e96a..0000000000
--- a/test/integration/targets/mongodb_replicaset/defaults/main.yml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-# defaults file for test_mongodb_replicaset
-mongodb_replicaset1: rs1
-mongodb_replicaset2: rs2
-mongodb_replicaset3: rs3
-mongodb_replicaset4: rs4
-mongodb_replicaset5: rs5
-mongodb_replicaset6: rs6
-mongodb_replicaset7: rs7
-mongodb_replicaset8: rs8
-test_mongo_auth: yes
-mongodb_admin_user: test_root
-mongodb_admin_password: saE_Rr9!gE6gh#e~R#nZ
-debug: False
-mongodb_nodes:
- - 3001
- - 3002
- - 3003
-mongod_auth: false
-kill_signal: SIGTERM
-# Should be one of
-mongod_storage_engine_opts: "--storageEngine wiredTiger --wiredTigerEngineConfigString='cache_size=200M'"
-#mongod_storage_engine_opts: "--storageEngine mmapv1 --nojournal"
-mongodb_user: mongodb
diff --git a/test/integration/targets/mongodb_replicaset/files/js/is_primary.js b/test/integration/targets/mongodb_replicaset/files/js/is_primary.js
deleted file mode 100644
index 7bb130614f..0000000000
--- a/test/integration/targets/mongodb_replicaset/files/js/is_primary.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var done = false;
-var iterations = 0;
-while(rs.status()['myState'] != 1) {
- if (!done) {
- //print("State is not yet PRIMARY. Waiting...");
- done = true
- }
- sleep(1000);
- iterations++;
- if (iterations == 100) {
- throw new Error("Exceeded iterations limit.");
- }
- }
diff --git a/test/integration/targets/mongodb_replicaset/meta/main.yml b/test/integration/targets/mongodb_replicaset/meta/main.yml
deleted file mode 100644
index 9d941be0bc..0000000000
--- a/test/integration/targets/mongodb_replicaset/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
- - setup_mongodb
- - setup_remote_tmp_dir
diff --git a/test/integration/targets/mongodb_replicaset/tasks/main.yml b/test/integration/targets/mongodb_replicaset/tasks/main.yml
deleted file mode 100644
index 72d00e4d58..0000000000
--- a/test/integration/targets/mongodb_replicaset/tasks/main.yml
+++ /dev/null
@@ -1,540 +0,0 @@
-# test code for the mongodb_replicaset module
-# (c) 2019, Rhys Campbell <rhys.james.campbell@googlemail.com>
-
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# ============================================================
-
-- name: Ensure tests home exists
- file:
- path: "{{ remote_tmp_dir }}/tests"
- state: directory
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset1 }}"
-
-- include_tasks: mongod_replicaset.yml
-
-# test with yaml list
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset1 }}"
- heartbeat_timeout_secs: 1
- election_timeout_millis: 1000
- members:
- - "localhost:3001"
- - "localhost:3002"
- - "localhost:3003"
-
-- name: Ensure is_primary script exists on host
- copy:
- src: js/is_primary.js
- dest: "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.status()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
-
-- name: Add mongodb admin user
- mongodb_user:
- login_host: localhost
- login_port: 3001
- replica_set: "{{ mongodb_replicaset1 }}"
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: ["root"]
- state: present
- register: mongo_admin_user
- when: test_mongo_auth
-
-- name: Murder all mongod processes
- shell: pkill -{{ kill_signal }} mongod;
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- with_items: "{{ pids_of_mongod.pids }}"
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset1 }}"
-
-- set_fact:
- mongod_auth: true
-
-- name: Execute mongod script to restart with auth enabled
- include_tasks: mongod_replicaset.yml
-
-- name: Validate replicaset previously created
- mongodb_replicaset:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset1 }}"
- election_timeout_millis: 1000
- members:
- - "localhost:3001"
- - "localhost:3002"
- - "localhost:3003"
- register: mongodb_replicaset
-
-- name: Assert replicaset name has not changed
- assert:
- that: mongodb_replicaset.changed == False
-
-- name: Test with bad password
- mongodb_replicaset:
- login_user: "{{ mongodb_admin_user }}"
- login_password: XXXXXXXXXXXXXXXX
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset1 }}"
- election_timeout_millis: 1000
- members:
- - "localhost:3001"
- - "localhost:3002"
- - "localhost:3003"
- register: mongodb_replicaset_bad_pw
- ignore_errors: True
-
-- name: Assert login failed
- assert:
- that:
- - "mongodb_replicaset_bad_pw.rc == 1"
- - "'Authentication failed' in mongodb_replicaset_bad_pw.module_stderr"
-
- #############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset2 }}"
-
-- set_fact:
- mongod_auth: false
-
-- name: Execute mongod script to restart with auth enabled
- include_tasks: mongod_replicaset.yml
-
-# Test with python style list
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset2 }}"
- members: [ "localhost:3001", "localhost:3002", "localhost:3003" ]
- election_timeout_millis: 1000
- heartbeat_timeout_secs: 1
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.status()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset2 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
-
-#############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset3 }}"
-
-- set_fact:
- mongod_auth: false
-
-- name: Launch mongod processes
- include_tasks: mongod_replicaset.yml
-
-# Test with csv string
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset3 }}"
- members: "localhost:3001,localhost:3002,localhost:3003"
- election_timeout_millis: 1000
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.status()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset3 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
-
- #############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset4 }}"
-
-- set_fact:
- mongod_auth: false
-
-- name: Launch mongod processes
- include_tasks: mongod_replicaset.yml
-
-# Test with arbiter_at_index
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- arbiter_at_index: 2
- replica_set: "{{ mongodb_replicaset4 }}"
- members: "localhost:3001,localhost:3002,localhost:3003"
- election_timeout_millis: 1000
-
-- name: Ensure host reaches primary before proceeding 3001
- command: mongo admin --port 3001 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.status()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset4 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
- - "'ARBITER' in mongo_output.stdout"
-
-#############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset5 }}"
-
-- set_fact:
- mongod_auth: false
-
-- name: Launch mongod processes
- include_tasks: mongod_replicaset.yml
-
-# Test with chainingAllowed
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- chaining_allowed: no
- replica_set: "{{ mongodb_replicaset5 }}"
- election_timeout_millis: 1000
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.conf()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset5 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
- - "'chainingAllowed\" : false,' in mongo_output.stdout"
-
-#############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset6 }}"
-
-- set_fact:
- mongodb_nodes: [ 3001, 3002, 3003, 3004, 3005]
-
-- set_fact:
- mongod_auth: false
-
-- name: Launch mongod processes
- include_tasks: mongod_replicaset.yml
-
-# Test with 5 mongod processes
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset6 }}"
- election_timeout_millis: 1000
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
- - localhost:3004
- - localhost:3005
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.conf()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset6 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
- - "'localhost:3004' in mongo_output.stdout"
- - "'localhost:3005' in mongo_output.stdout"
-
-#############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset7 }}"
-
-- set_fact:
- mongod_auth: false
-
-- set_fact:
- mongodb_nodes: [ 3001, 3002, 3003 ]
-
-- name: Launch mongod processes
- include_tasks: mongod_replicaset.yml
-
-# Test withheartbeatTimeoutSecs
-- name: Create replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- election_timeout_millis: 9999
- replica_set: "{{ mongodb_replicaset7 }}"
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.conf()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset7 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
- - "'electionTimeoutMillis\" : 9999,' in mongo_output.stdout"
-
-#############################################################
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset8 }}"
-
-- name: Launch mongod processes
- include_tasks: mongod_replicaset.yml
-
-# Test with heartbeatTimeoutSecs
-- name: Create replicaset with module protocolVersion 0 (Mongodb 3.0)
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- protocol_version: 0
- heartbeat_timeout_secs: 9
- replica_set: "{{ mongodb_replicaset8 }}"
- election_timeout_millis: 1000
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
- when: mongodb_version.startswith('3') == True
-
-- name: Create replicaset with module protocolVersion 1 (MongoDB 4.0+)
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- protocol_version: 1
- election_timeout_millis: 9000
- replica_set: "{{ mongodb_replicaset8 }}"
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
- when: mongodb_version.startswith('4') == True
-
-- name: Get replicaset info
- command: mongo admin --eval "rs.conf()" --port 3001
- register: mongo_output
-
-- name: Assert replicaset name is in mongo_output MongoDB 3.0+
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset8 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
- - "'heartbeatTimeoutSecs\" : 9,' in mongo_output.stdout"
- when: mongodb_version.startswith('3') == True
-
-- name: Assert replicaset name is in mongo_output MongoDB 4.0+
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset8 }}' in mongo_output.stdout"
- - "'localhost:3001' in mongo_output.stdout"
- - "'localhost:3002' in mongo_output.stdout"
- - "'localhost:3003' in mongo_output.stdout"
- - "'electionTimeoutMillis\" : 9000,' in mongo_output.stdout"
- when: mongodb_version.startswith('4') == True
-
-# TODO - Readd this test once we support serverSelectionTimeoutMS / connectTimeoutMS
-#- name: Run test with unknown host
-# mongodb_replicaset:
-# login_user: admin
-# login_password: secret
-# login_host: "idonotexist"
-# login_port: 3001
-# login_database: "admin"
-# protocol_version: 0
-# heartbeat_timeout_secs: 9
-# replica_set: "{{ mongodb_replicaset8 }}"
-# election_timeout_millis: 1000
-# members:
-# - idonotexist:3001
-# - idonotexist:3002
-# - idonotexist:3003
-# ignore_errors: True
-# register: host_does_not_exist
-
-#- name: Assert that "Name or service not known" is in error
-# assert:
-# that:
-# - "host_does_not_exist.rc == 1"
-# - "'Name or service not known' in host_does_not_exist.module_stderr"
-
-# Final clean up to prevent "directory not empty" error
-
-# Test invalid arbiter handling
-# Test with arbiter_at_index
-- name: Test invalid arbiter handling 1
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- arbiter_at_index: 0
- replica_set: "{{ mongodb_replicaset4 }}"
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
- - localhost:3004
- ignore_errors: yes
- register: invalid_num
-
-- assert:
- that:
- - "'MongoDB Replicaset validation failed. Invalid number of replicaset members.' == invalid_num.msg"
-
-- name: Test invalid arbiter handling 2
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- arbiter_at_index: 4
- replica_set: "{{ mongodb_replicaset4 }}"
- members:
- - localhost:3001
- - localhost:3002
- - localhost:3003
- ignore_errors: yes
- register: invalid_num2
-
-- assert:
- that:
- - "'MongoDB Replicaset validation failed. Invalid arbiter index.' == invalid_num2.msg"
-
-- include_tasks: mongod_teardown.yml
diff --git a/test/integration/targets/mongodb_replicaset/tasks/mongod_replicaset.yml b/test/integration/targets/mongodb_replicaset/tasks/mongod_replicaset.yml
deleted file mode 100644
index f33d93f4ac..0000000000
--- a/test/integration/targets/mongodb_replicaset/tasks/mongod_replicaset.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-- name: Set mongodb_user user for redhat
- set_fact:
- mongodb_user: "mongod"
- when: ansible_os_family == "RedHat"
-
-- name: Create directories for mongod processes
- file:
- path: "{{ remote_tmp_dir }}/mongod{{ item }}"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
- recurse: yes
- with_items: "{{ mongodb_nodes }}"
-
-- name: Create keyfile
- copy:
- dest: "{{ remote_tmp_dir }}/my.key"
- content: |
- fd2CUrbXBJpB4rt74A6F
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0600
- when: mongod_auth == True
-
-- name: Spawn mongod process without auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == False
-
-- name: Spawn mongod process with auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork --auth --keyFile my.key
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == True
-
-- name: Wait for mongod to start responding
- wait_for:
- port: "{{ item }}"
- with_items: "{{ mongodb_nodes }}"
diff --git a/test/integration/targets/mongodb_replicaset/tasks/mongod_teardown.yml b/test/integration/targets/mongodb_replicaset/tasks/mongod_teardown.yml
deleted file mode 100644
index 7bc5d3d0a0..0000000000
--- a/test/integration/targets/mongodb_replicaset/tasks/mongod_teardown.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-- name: Kill all mongod processes
- command: pkill -{{ kill_signal }} mongod
- ignore_errors: true
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- delay: 1
- with_items: "{{ pids_of_mongod }}"
-
-- name: Remove all mongod folders
- file:
- path: "{{ remote_tmp_dir }}/{{ item }}"
- state: absent
- with_items:
- - mongod3001
- - mongod3002
- - mongod3003
-
-- name: Remove all mongod sock files
- shell: rm -Rf /tmp/mongodb*.sock
diff --git a/test/integration/targets/mongodb_shard/aliases b/test/integration/targets/mongodb_shard/aliases
deleted file mode 100644
index 8251a83e7f..0000000000
--- a/test/integration/targets/mongodb_shard/aliases
+++ /dev/null
@@ -1,7 +0,0 @@
-destructive
-shippable/posix/group1
-skip/aix
-skip/osx
-skip/freebsd
-skip/rhel
-needs/root
diff --git a/test/integration/targets/mongodb_shard/defaults/main.yml b/test/integration/targets/mongodb_shard/defaults/main.yml
deleted file mode 100644
index 7ad82d6806..0000000000
--- a/test/integration/targets/mongodb_shard/defaults/main.yml
+++ /dev/null
@@ -1,16 +0,0 @@
----
-# defaults file for test_mongodb_shard
-mongodb_replicaset1: rs1
-mongodb_replicaset2: rs2
-configsrv_replicaset: cfg
-test_mongo_auth: yes
-mongodb_admin_user: test_root
-mongodb_admin_password: saE_Rr9!gE6gh#e~R#nZ
-debug: yes
-mongod_auth: false
-kill_signal: SIGTERM
-# Should be one of
-# --storageEngine wiredTiger --wiredTigerEngineConfigString="cache_size=200M"
-# --storageEngine mmapv1 --nojournal
-mongod_storage_engine_opts: "--storageEngine wiredTiger --wiredTigerEngineConfigString='cache_size=200M'"
-mongodb_user: mongodb
diff --git a/test/integration/targets/mongodb_shard/files/bash/ensure_primary.sh.j2 b/test/integration/targets/mongodb_shard/files/bash/ensure_primary.sh.j2
deleted file mode 100644
index cff0638f10..0000000000
--- a/test/integration/targets/mongodb_shard/files/bash/ensure_primary.sh.j2
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env bash
-
-# This script is here because on some occassions the head mongodb does not become primary.
-
-PRIMARY=$1;
-AUTH=$2;
-
-if [ "$AUTH" == "1" ]; then
- if [ "$PRIMARY" == "3001" ]; then
- mongo admin --port 3002 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.freeze(120)";
- mongo admin --port 3003 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.freeze(120)";
- mongo admin --port 3002 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.stepDown()";
- mongo admin --port 3003 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.stepDown()";
- elif [ "$PRIMARY" == "3004" ]; then
- mongo admin --port 3005 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.freeze(120)";
- mongo admin --port 3006 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.freeze(120)";
- mongo admin --port 3005 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.stepDown()";
- mongo admin --port 3006 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} --eval "rs.stepDown()";
- else
- echo "Unsupported port!";
- exit 1;
- fi;
-else
- if [ "$PRIMARY" == "3001" ]; then
- mongo admin --port 3002 --eval "rs.freeze(120)";
- mongo admin --port 3003 --eval "rs.freeze(120)";
- mongo admin --port 3002 --eval "rs.stepDown()";
- mongo admin --port 3003 --eval "rs.stepDown()";
- elif [ "$PRIMARY" == "3004" ]; then
- mongo admin --port 3005 --eval "rs.freeze(120)";
- mongo admin --port 3006 --eval "rs.freeze(120)";
- mongo admin --port 3005 --eval "rs.stepDown()";
- mongo admin --port 3006 --eval "rs.stepDown()";
- else
- echo "Unsupported port!";
- exit 1;
- fi;
-fi;
diff --git a/test/integration/targets/mongodb_shard/files/js/is_primary.js b/test/integration/targets/mongodb_shard/files/js/is_primary.js
deleted file mode 100644
index 7bb130614f..0000000000
--- a/test/integration/targets/mongodb_shard/files/js/is_primary.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var done = false;
-var iterations = 0;
-while(rs.status()['myState'] != 1) {
- if (!done) {
- //print("State is not yet PRIMARY. Waiting...");
- done = true
- }
- sleep(1000);
- iterations++;
- if (iterations == 100) {
- throw new Error("Exceeded iterations limit.");
- }
- }
diff --git a/test/integration/targets/mongodb_shard/meta/main.yml b/test/integration/targets/mongodb_shard/meta/main.yml
deleted file mode 100644
index 9d941be0bc..0000000000
--- a/test/integration/targets/mongodb_shard/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
- - setup_mongodb
- - setup_remote_tmp_dir
diff --git a/test/integration/targets/mongodb_shard/tasks/main.yml b/test/integration/targets/mongodb_shard/tasks/main.yml
deleted file mode 100644
index 53f9b2d222..0000000000
--- a/test/integration/targets/mongodb_shard/tasks/main.yml
+++ /dev/null
@@ -1,458 +0,0 @@
-# test code for the mongodb_shard module
-# (c) 2019, Rhys Campbell <rhys.james.campbell@googlemail.com>
-
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# ============================================================
-
-- name: Ensure tests home exists
- file:
- path: "{{ remote_tmp_dir }}/tests"
- state: directory
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset1 }}"
-
-- set_fact:
- mongodb_nodes: [ 3001, 3002, 3003 ]
-
-- include_tasks: mongod_replicaset.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset2 }}"
-
-- set_fact:
- mongodb_nodes: [ 3004, 3005, 3006 ]
-
-- include_tasks: mongod_replicaset.yml
-
-- name: Launch cfg server
- command: mongod --configsvr --port 4000 --dbpath {{ remote_tmp_dir }}/config --logpath {{ remote_tmp_dir }}/config.log --smallfiles --replSet "{{ configsrv_replicaset }}" --fork
-
-- name: Create replicaset1 with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset1 }}"
- members:
- - "localhost:3001"
- - "localhost:3002"
- - "localhost:3003"
-
-- name: Create replicaset2 with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3004
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset2 }}"
- members:
- - "localhost:3004"
- - "localhost:3005"
- - "localhost:3006"
-
-- name: Create config srv replicaset with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 4000
- login_database: "admin"
- replica_set: "{{ configsrv_replicaset }}"
- validate: no
- members:
- - "localhost:4000"
-
-- name: Get config server replset mongo_output
- command: mongo admin --port 4000 --eval "rs.status();"
- register: cfg_replset_output
-
-- name: Assert that replset is a config server
- assert:
- that:
- - "'\"configsvr\" : true' in cfg_replset_output.stdout"
- - "'\"set\" : \"{{ configsrv_replicaset }}\"' in cfg_replset_output.stdout"
-
-- name: Launch mongos
- command: mongos --configdb "{{ configsrv_replicaset }}/localhost:4000" --logpath "{{ remote_tmp_dir }}/tests/mongos.log" --port 27017 --fork
-
-- name: Ensure is_primary script exists on host
- copy:
- src: js/is_primary.js
- dest: "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Ensure host reaches primary before proceeding 3001
- command: mongo admin --port 3001 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Ensure host reaches primary before proceeding 3004
- command: mongo admin --port 3004 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Add shard 1
- mongodb_shard:
- login_user: admin
- login_password: admin
- shard: "{{ mongodb_replicaset1 }}/localhost:3001"
- state: present
-
-- name: Add shard 2
- mongodb_shard:
- login_user: admin
- login_password: admin
- shard: "{{ mongodb_replicaset2 }}/localhost:3004"
- state: present
-
-- name: Get replicaset info
- command: mongo admin --eval "sh.status()" --port 27017
- register: mongo_output
-
-- name: Assert shard name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}/localhost:3001,localhost:3002,localhost:3003' in mongo_output.stdout"
- - "'{{ mongodb_replicaset2 }}/localhost:3004,localhost:3005,localhost:3006' in mongo_output.stdout"
- - "'balancer' in mongo_output.stdout"
-
-- name: Remove shard 2
- mongodb_shard:
- login_user: admin
- login_password: admin
- shard: "{{ mongodb_replicaset2 }}"
- state: absent
-
-- name: Get replicaset info
- command: mongo admin --eval "sh.status()" --port 27017
- register: mongo_output
-
-- name: Assert shard 2 is draining
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}/localhost:3001,localhost:3002,localhost:3003' in mongo_output.stdout"
- - "'\"draining\" : true' in mongo_output.stdout"
- - "'balancer' in mongo_output.stdout"
-
-- name: Run remove command again to finalize shard removal
- mongodb_shard:
- login_user: admin
- login_password: admin
- shard: "{{ mongodb_replicaset2 }}"
- state: absent
-
-- name: Get replicaset info
- command: mongo admin --eval "sh.status()" --port 27017
- register: mongo_output
-
-- name: Assert shard 2 is not present
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}/localhost:3001,localhost:3002,localhost:3003' in mongo_output.stdout"
- - "'{{ mongodb_replicaset2 }}/localhost:3004,localhost:3005,localhost:3006' not in mongo_output.stdout"
- - "'balancer' in mongo_output.stdout"
-
-# Repeat of above with auth enabled
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset1 }}"
-
-- set_fact:
- mongodb_nodes: [ 3001, 3002, 3003 ]
-
-- include_tasks: mongod_replicaset.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset2 }}"
-
-- set_fact:
- mongodb_nodes: [ 3004, 3005, 3006 ]
-
-- include_tasks: mongod_replicaset.yml
-
-- name: Create replicaset1 with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3001
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset1 }}"
- members:
- - "localhost:3001"
- - "localhost:3002"
- - "localhost:3003"
-
-- name: Create replicaset2 with module
- mongodb_replicaset:
- login_user: admin
- login_password: secret
- login_host: "localhost"
- login_port: 3004
- login_database: "admin"
- replica_set: "{{ mongodb_replicaset2 }}"
- members:
- - "localhost:3004"
- - "localhost:3005"
- - "localhost:3006"
-
-- name: Launch cfg server
- command: mongod --configsvr --port 4000 --dbpath {{ remote_tmp_dir }}/config --logpath {{ remote_tmp_dir }}/config.log --smallfiles --replSet "{{ configsrv_replicaset }}" --fork
-
-- name: Create config srv replicaset with module
- mongodb_replicaset:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_port: 4000
- login_database: "admin"
- replica_set: "{{ configsrv_replicaset }}"
- validate: no
- members:
- - "localhost:4000"
-
-- name: Ensure host reaches primary before proceeding 3001
- command: mongo admin --port 3001 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Ensure host reaches primary before proceeding 3004
- command: mongo admin --port 3004 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Ensure host reaches primary before proceeding 4000
- command: mongo admin --port 4000 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Add mongodb admin user to each shard 3.4+
- mongodb_user:
- login_host: localhost
- login_port: "{{ item.port }}"
- replica_set: "{{ item.rs }}"
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: ["root"]
- state: present
- register: mongo_admin_user
- with_items:
- - { "port": 3001, "rs": "{{ mongodb_replicaset1 }}" }
- - { "port": 3004, "rs": "{{ mongodb_replicaset2 }}" }
- - { "port": 4000, "rs": "{{ configsrv_replicaset }}" }
- when: mongodb_version not in ["3.2", "4.0"] and test_mongo_auth == True
-
-- name: Add mongodb admin user to each shard 3.2 ^ 4.0
- mongodb_user:
- login_host: localhost
- login_port: "{{ item.port }}"
- replica_set: "{{ item.rs }}"
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: ["root"]
- state: present
- register: mongo_admin_user
- with_items:
- - { "port": 3001, "rs": "{{ mongodb_replicaset1 }}" }
- - { "port": 3004, "rs": "{{ mongodb_replicaset2 }}" }
- when: mongodb_version not in ["3.2", "4.0"] and test_mongo_auth == True
-
-# mongodb_user throws an error when creating a user on 3.2 (also on 4.0 with Ubuntu 18.04)
-# 'majority' is the only valid write concern when writing to config server replica sets
-- name: Copy create_user_root_3.2.js.j2 template to host
- template:
- src: create_user_root_3.2.js.j2
- dest: /root/create_user_root_3.2.js
- when: mongodb_version in ["3.2", "4.0"]
-
-- name: Copy script to host
- template:
- src: files/bash/ensure_primary.sh.j2
- dest: /root/ensure_primary.sh
-
-- name: Execute script for 3001
- script: /root/ensure_primary.sh 3001 0
-# We do this here because sometimes 3004 instance seems to be demoted
-- name: Execute script for 3004
- script: /root/ensure_primary.sh 3004 0
-
-- name: Create admin user on 3.2 and 4.0 config replset
- shell: mongo admin --port {{ item }} /root/create_user_root_3.2.js
- with_items:
- - 4000
- - 3001
- - 3004
- when: mongodb_version in ["3.2", "4.0"]
-
-- name: Murder all mongod processes
- shell: pkill -{{ kill_signal }} mongod || true;
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- with_items: "{{ pids_of_mongod }}"
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset1 }}"
-
-- set_fact:
- mongodb_nodes: [ 3001, 3002, 3003 ]
-
-- set_fact:
- mongod_auth: true
-
-- include_tasks: mongod_replicaset.yml
-
-- set_fact:
- current_replicaset: "{{ mongodb_replicaset2 }}"
-
-- set_fact:
- mongodb_nodes: [ 3004, 3005, 3006 ]
-
-- set_fact:
- mongod_auth: true
-
-- include_tasks: mongod_replicaset.yml
-
-- name: Launch cfg server with auth
- command: mongod --configsvr --port 4000 --dbpath {{ remote_tmp_dir }}/config --logpath {{ remote_tmp_dir }}/config.log --smallfiles --replSet "{{ configsrv_replicaset }}" --fork --auth --keyFile {{ remote_tmp_dir }}/my.key
-
-- name: Execute script for 3001
- script: /root/ensure_primary.sh 3001 1
-
-- name: Execute script for 3004
- script: /root/ensure_primary.sh 3004 1
-
-- name: Ensure host reaches primary before proceeding 3001
- command: mongo admin --port 3001 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Ensure host reaches primary before proceeding 3004
- command: mongo admin --port 3004 -u {{ mongodb_admin_user }} -p {{ mongodb_admin_password }} "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Launch mongos
- command: mongos --configdb "{{ configsrv_replicaset }}/localhost:4000" --logpath "{{ remote_tmp_dir }}/mongos.log" --port 27017 --fork --keyFile {{ remote_tmp_dir }}/my.key
-
-- name: Wait for mongos to become active
- wait_for:
- host: localhost
- port: 4000
- delay: 1
-
-- name: Add shard 1
- mongodb_shard:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- shard: "{{ mongodb_replicaset1 }}/localhost:3001"
- state: present
-
-- name: Add shard 2
- mongodb_shard:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- shard: "{{ mongodb_replicaset2 }}/localhost:3004"
- state: present
-
-- name: Test with bad password
- mongodb_shard:
- login_user: "{{ mongodb_admin_user }}"
- login_password: XXXXXXXXXXXX
- shard: "{{ mongodb_replicaset2 }}/localhost:3004"
- state: present
- register: mongodb_shard_bad_pw
- ignore_errors: True
-
-- name: Assert login failed
- assert:
- that:
- - "mongodb_shard_bad_pw.changed == False"
- - "'unable to connect to database: Authentication failed.' == mongodb_shard_bad_pw.msg"
-
-- name: Get replicaset info
- command: mongo admin --eval "sh.status()" --port 27017 -u "{{ mongodb_admin_user }}" -p "{{ mongodb_admin_password }}"
- register: mongo_output
-
-- name: Assert shard name is in mongo_output
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}/localhost:3001,localhost:3002,localhost:3003' in mongo_output.stdout"
- - "'{{ mongodb_replicaset2 }}/localhost:3004,localhost:3005,localhost:3006' in mongo_output.stdout"
- - "'balancer' in mongo_output.stdout"
-
-- name: Remove shard 2
- mongodb_shard:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- shard: "{{ mongodb_replicaset2 }}"
- state: absent
-
-- name: Get replicaset info
- command: mongo admin --eval "sh.status()" --port 27017 -u "{{ mongodb_admin_user }}" -p "{{ mongodb_admin_password }}"
- register: mongo_output
-
-- name: Assert shard 2 is draining
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}/localhost:3001,localhost:3002,localhost:3003' in mongo_output.stdout"
- - "'\"draining\" : true' in mongo_output.stdout"
- - "'balancer' in mongo_output.stdout"
-
-- name: Run remove command again to finalize shard removal
- mongodb_shard:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- shard: "{{ mongodb_replicaset2 }}"
- state: absent
-
-- name: Get replicaset info
- command: mongo admin --eval "sh.status()" --port 27017 -u "{{ mongodb_admin_user }}" -p "{{ mongodb_admin_password }}"
- register: mongo_output
-
-- name: Assert shard 2 is not present
- assert:
- that:
- - "mongo_output.changed == true"
- - "'{{ mongodb_replicaset1 }}/localhost:3001,localhost:3002,localhost:3003' in mongo_output.stdout"
- - "'{{ mongodb_replicaset2 }}/localhost:3004,localhost:3005,localhost:3006' not in mongo_output.stdout"
- - "'balancer' in mongo_output.stdout"
-
-# TODO - Readd this test once we support serverSelectionTimeoutMS / connectTimeoutMS
-#- name: Run test with unknown host
-# mongodb_shard:
-# login_user: "{{ mongodb_admin_user }}"
-# login_password: "{{ mongodb_admin_password }}"
-# login_host: "idonotexist"
-# shard: "{{ mongodb_replicaset2 }}"
-# state: absent
-# ignore_errors: True
-# register: host_does_not_exist
-
-#- name: Assert that "Name or service not known" is in error
-# assert:
-# that:
-# - "host_does_not_exist.changed == False"
-# - "'unable to connect to database: idonotexist:27017: [Errno -2] Name or service not known' == host_does_not_exist.msg"
-
-# Final clean up to prevent "directory not empty" error
-- include_tasks: mongod_teardown.yml
diff --git a/test/integration/targets/mongodb_shard/tasks/mongod_replicaset.yml b/test/integration/targets/mongodb_shard/tasks/mongod_replicaset.yml
deleted file mode 100644
index fe1c2ffe62..0000000000
--- a/test/integration/targets/mongodb_shard/tasks/mongod_replicaset.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-- name: Set mongodb_user user for redhat
- set_fact:
- mongodb_user: "mongod"
- when: ansible_os_family == "RedHat"
-
-- name: Create directories for mongod processes
- file:
- path: "{{ remote_tmp_dir }}/mongod{{ item }}"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
- recurse: yes
- with_items: "{{ mongodb_nodes }}"
-
-- name: Ensure {{ remote_tmp_dir }}/config dir exists
- file:
- path: "{{ remote_tmp_dir }}/config"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
-
-- name: Create keyfile
- copy:
- dest: "{{ remote_tmp_dir }}/my.key"
- content: |
- fd2CUrbXBJpB4rt74A6F
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0600
- when: mongod_auth == True
-
-- name: Spawn mongod process without auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == False
-
-- name: Spawn mongod process with auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork --auth --keyFile my.key
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == True
-
-- name: Wait for mongod to start responding
- wait_for:
- port: "{{ item }}"
- with_items: "{{ mongodb_nodes }}"
diff --git a/test/integration/targets/mongodb_shard/tasks/mongod_teardown.yml b/test/integration/targets/mongodb_shard/tasks/mongod_teardown.yml
deleted file mode 100644
index 3af09d59be..0000000000
--- a/test/integration/targets/mongodb_shard/tasks/mongod_teardown.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-- name: Kill all mongod processes
- command: pkill -{{ kill_signal }} mongod
- ignore_errors: true
-
-- name: Kill all mongos processes
- command: pkill -{{ kill_signal }} mongos
- ignore_errors: true
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- delay: 1
- with_items: "{{ pids_of_mongod }}"
-
-- name: Remove all mongod folders
- file:
- path: "{{ remote_tmp_dir }}/{{ item }}"
- state: absent
- with_items:
- - mongod3001
- - mongod3002
- - mongod3003
- - mongod3004
- - mongod3005
- - mongod3006
- - config
-
-- name: Remove all mongod sock files
- shell: rm -Rf /tmp/mongodb*.sock
diff --git a/test/integration/targets/mongodb_shard/templates/create_user_root_3.2.js.j2 b/test/integration/targets/mongodb_shard/templates/create_user_root_3.2.js.j2
deleted file mode 100644
index 368cb966bf..0000000000
--- a/test/integration/targets/mongodb_shard/templates/create_user_root_3.2.js.j2
+++ /dev/null
@@ -1,8 +0,0 @@
-db.createUser(
- {
- user: "{{ mongodb_admin_user }}",
- pwd: "{{ mongodb_admin_password }}",
- roles: [ { role: "root", db: "admin" } ]
- },
- { w: "majority", j: true, wtimeout: 10000 }
-)
diff --git a/test/integration/targets/mongodb_user/aliases b/test/integration/targets/mongodb_user/aliases
deleted file mode 100644
index 0aa5f9a9bf..0000000000
--- a/test/integration/targets/mongodb_user/aliases
+++ /dev/null
@@ -1,8 +0,0 @@
-destructive
-shippable/posix/group1
-skip/aix
-skip/osx
-skip/freebsd
-skip/rhel
-needs/root
-disabled
diff --git a/test/integration/targets/mongodb_user/defaults/main.yml b/test/integration/targets/mongodb_user/defaults/main.yml
deleted file mode 100644
index aac55526df..0000000000
--- a/test/integration/targets/mongodb_user/defaults/main.yml
+++ /dev/null
@@ -1,21 +0,0 @@
----
-# defaults file for test_mongodb_user
-mongodb_admin_user: test_root
-mongodb_admin_password: saE_Rr9!gE6gh#e~R#nZ
-mongod_auth: false
-kill_signal: SIGTERM
-# Should be one of
-# --storageEngine wiredTiger --wiredTigerEngineConfigString="cache_size=200M"
-# --storageEngine mmapv1 --nojournal
-mongod_storage_engine_opts: "--storageEngine wiredTiger --wiredTigerEngineConfigString='cache_size=200M'"
-mongodb_user: mongodb
-mongodb_user_list:
- - { "name": "user1", "password": "password1", "roles": "read", "database": "test" }
- - { "name": "user2", "password": "password2", "roles": "readWrite", "database": "test" }
- - { "name": "user3", "password": "password3", "roles": "dbAdmin", "database": "test" }
- - { "name": "user4", "password": "password4", "roles": "userAdmin", "database": "test" }
- - { "name": "user5", "password": "password5", "roles": "clusterAdmin", "database": "admin" }
- - { "name": "user6", "password": "password6", "roles": "readAnyDatabase", "database": "admin" }
- - { "name": "user7", "password": "password7", "roles": "readWriteAnyDatabase", "database": "admin" }
- - { "name": "user8", "password": "password8", "roles": "userAdminAnyDatabase", "database": "admin" }
- - { "name": "user9", "password": "password9", "roles": "dbAdminAnyDatabase", "database": "admin" }
diff --git a/test/integration/targets/mongodb_user/files/js/is_primary.js b/test/integration/targets/mongodb_user/files/js/is_primary.js
deleted file mode 100644
index 7bb130614f..0000000000
--- a/test/integration/targets/mongodb_user/files/js/is_primary.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var done = false;
-var iterations = 0;
-while(rs.status()['myState'] != 1) {
- if (!done) {
- //print("State is not yet PRIMARY. Waiting...");
- done = true
- }
- sleep(1000);
- iterations++;
- if (iterations == 100) {
- throw new Error("Exceeded iterations limit.");
- }
- }
diff --git a/test/integration/targets/mongodb_user/meta/main.yml b/test/integration/targets/mongodb_user/meta/main.yml
deleted file mode 100644
index 9d941be0bc..0000000000
--- a/test/integration/targets/mongodb_user/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
- - setup_mongodb
- - setup_remote_tmp_dir
diff --git a/test/integration/targets/mongodb_user/tasks/main.yml b/test/integration/targets/mongodb_user/tasks/main.yml
deleted file mode 100644
index f2f061f2c4..0000000000
--- a/test/integration/targets/mongodb_user/tasks/main.yml
+++ /dev/null
@@ -1,226 +0,0 @@
-# test code for the mongodb_user module
-# (c) 2019, Rhys Campbell <rhys.james.campbell@googlemail.com>
-
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# ============================================================
-
-- name: Ensure tests home exists
- file:
- path: "{{ remote_tmp_dir }}/tests"
- state: directory
-
-- include_tasks: mongod_teardown.yml
-
-- set_fact:
- current_replicaset: mongodb_user_tests_replicaset
-
-- set_fact:
- mongodb_nodes: [ 3001, 3002, 3003 ]
-
-- include_tasks: mongod_replicaset.yml
-
-- name: Create current_replicaset with module
- mongodb_replicaset:
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- members:
- - "localhost:3001"
- - "localhost:3002"
- - "localhost:3003"
-
-- name: Ensure is_primary script exists on host
- copy:
- src: js/is_primary.js
- dest: "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Ensure host reaches primary before proceeding 3001
- command: mongo admin --port 3001 "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Create admin user with module
- mongodb_user:
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: root
- state: present
- register: mongodb_admin_user_created
-
-- assert:
- that:
- - mongodb_admin_user_created.changed == True
-
-- name: Kill all mongod processes
- command: pkill -{{ kill_signal }} mongod
- ignore_errors: true
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- delay: 3
- with_items: "{{ pids_of_mongod }}"
-
-- set_fact:
- mongod_auth: true
-
-- include_tasks: mongod_replicaset.yml
-# Tests with auth enable
-
-- name: Ensure host reaches primary before proceeding 3001
- command: mongo admin --port 3001 --username "{{ mongodb_admin_user }}" --password "{{ mongodb_admin_password }}" "{{ remote_tmp_dir }}/tests/is_primary.js"
-
-- name: Run admin user creation again
- mongodb_user:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_database: admin
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: root
- state: present
- update_password: on_create
- register: mongodb_admin_user_created
-
-- assert:
- that:
- - mongodb_admin_user_created.changed == False
-
-- name: Run admin user creation again with forced pw update
- mongodb_user:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_database: admin
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- database: admin
- name: "{{ mongodb_admin_user }}"
- password: "{{ mongodb_admin_password }}"
- roles: root
- state: present
- update_password: always
- register: mongodb_admin_user_created
-
-- assert:
- that:
- - mongodb_admin_user_created.changed == True
-
-- name: Run user creation
- mongodb_user:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_database: admin
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- database: "{{ item.database }}"
- name: "{{ item.name }}"
- password: "{{ item.password }}"
- roles: "{{ item.roles }}"
- state: present
- with_items: "{{ mongodb_user_list }}"
-
-- name: Test login for all users
- shell: mongo "{{ item.database }}" --port 3001 --username "{{ item.name }}" --password "{{ item.password }}" --eval "printjson(db.getCollectionNames())"
- with_items: "{{ mongodb_user_list }}"
- register: login_test
-
-- name: Assert all logins successful
- assert:
- that: "{{ item.rc == 0 }}"
- with_items: "{{ login_test.results }}"
-
-- name: Get admin db users
- shell: mongo admin --port 3001 --username "{{ mongodb_admin_user }}" --password "{{ mongodb_admin_password }}" --eval "printjson(db.getUsers())"
- register: admin_db_users
-
-- name: Assert that roles exist in admin db output
- assert:
- that:
- - "'clusterAdmin' in admin_db_users.stdout"
- - "'readAnyDatabase' in admin_db_users.stdout"
- - "'readWriteAnyDatabase' in admin_db_users.stdout"
- - "'userAdminAnyDatabase' in admin_db_users.stdout"
- - "'dbAdminAnyDatabase' in admin_db_users.stdout"
-
-- name: Get test db users
- shell: mongo test --authenticationDatabase admin --port 3001 --username "{{ mongodb_admin_user }}" --password "{{ mongodb_admin_password }}" --eval "printjson(db.getUsers())"
- register: test_db_users
-
-- name: Assert that roles exist in test db output
- assert:
- that:
- - "'\"read\"' in test_db_users.stdout"
- - "'readWrite' in test_db_users.stdout"
- - "'dbAdmin' in test_db_users.stdout"
- - "'userAdmin' in test_db_users.stdout"
-
-- name: Drop users in test db
- mongodb_user:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_database: admin
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- database: "{{ item.database }}"
- name: "{{ item.name }}"
- state: absent
- with_items: "{{ mongodb_user_list }}"
- when: item.database == "test"
-
-- name: Get test db users
- shell: mongo test --authenticationDatabase admin --port 3001 --username "{{ mongodb_admin_user }}" --password "{{ mongodb_admin_password }}" --eval "printjson(db.getUsers())"
- register: test_db_users
-
-- name: Assert that roles do not exist in test db output
- assert:
- that:
- - "'user1' not in test_db_users.stdout"
- - "'user2' not in test_db_users.stdout"
- - "'user3' not in test_db_users.stdout"
- - "'user4' not in test_db_users.stdout"
-
-- name: Create user with multiple roles in test db
- mongodb_user:
- login_user: "{{ mongodb_admin_user }}"
- login_password: "{{ mongodb_admin_password }}"
- login_database: admin
- login_port: 3001
- replica_set: "{{ current_replicaset }}"
- database: test
- name: test_multiple_roles
- password: secret
- roles: readWrite,dbAdmin,userAdmin
- state: present
-
-- name: Get test db users
- shell: mongo test --authenticationDatabase admin --port 3001 --username "{{ mongodb_admin_user }}" --password "{{ mongodb_admin_password }}" --eval "printjson(db.getUsers())"
- register: test_db_users
-
-- debug:
- var: test_db_users
-
-# Clean up
-- include_tasks: mongod_teardown.yml
diff --git a/test/integration/targets/mongodb_user/tasks/mongod_replicaset.yml b/test/integration/targets/mongodb_user/tasks/mongod_replicaset.yml
deleted file mode 100644
index fe1c2ffe62..0000000000
--- a/test/integration/targets/mongodb_user/tasks/mongod_replicaset.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-- name: Set mongodb_user user for redhat
- set_fact:
- mongodb_user: "mongod"
- when: ansible_os_family == "RedHat"
-
-- name: Create directories for mongod processes
- file:
- path: "{{ remote_tmp_dir }}/mongod{{ item }}"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
- recurse: yes
- with_items: "{{ mongodb_nodes }}"
-
-- name: Ensure {{ remote_tmp_dir }}/config dir exists
- file:
- path: "{{ remote_tmp_dir }}/config"
- state: directory
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0755
-
-- name: Create keyfile
- copy:
- dest: "{{ remote_tmp_dir }}/my.key"
- content: |
- fd2CUrbXBJpB4rt74A6F
- owner: "{{ mongodb_user }}"
- group: "{{ mongodb_user }}"
- mode: 0600
- when: mongod_auth == True
-
-- name: Spawn mongod process without auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == False
-
-- name: Spawn mongod process with auth
- command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork --auth --keyFile my.key
- args:
- chdir: "{{ remote_tmp_dir }}"
- with_items: "{{ mongodb_nodes | sort }}"
- when: mongod_auth == True
-
-- name: Wait for mongod to start responding
- wait_for:
- port: "{{ item }}"
- with_items: "{{ mongodb_nodes }}"
diff --git a/test/integration/targets/mongodb_user/tasks/mongod_teardown.yml b/test/integration/targets/mongodb_user/tasks/mongod_teardown.yml
deleted file mode 100644
index 7bc5d3d0a0..0000000000
--- a/test/integration/targets/mongodb_user/tasks/mongod_teardown.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-- name: Kill all mongod processes
- command: pkill -{{ kill_signal }} mongod
- ignore_errors: true
-
-- name: Getting pids for mongod
- pids:
- name: mongod
- register: pids_of_mongod
-
-- name: Wait for all mongod processes to exit
- wait_for:
- path: "/proc/{{ item }}/status"
- state: absent
- delay: 1
- with_items: "{{ pids_of_mongod }}"
-
-- name: Remove all mongod folders
- file:
- path: "{{ remote_tmp_dir }}/{{ item }}"
- state: absent
- with_items:
- - mongod3001
- - mongod3002
- - mongod3003
-
-- name: Remove all mongod sock files
- shell: rm -Rf /tmp/mongodb*.sock
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 441c0fbb37..6bced3e4b2 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -1679,10 +1679,6 @@ lib/ansible/modules/commands/command.py validate-modules:nonexistent-parameter-d
lib/ansible/modules/commands/command.py validate-modules:parameter-list-no-elements
lib/ansible/modules/commands/command.py validate-modules:undocumented-parameter
lib/ansible/modules/commands/expect.py validate-modules:doc-missing-type
-lib/ansible/modules/database/mongodb/mongodb_parameter.py use-argspec-type-path
-lib/ansible/modules/database/mongodb/mongodb_replicaset.py use-argspec-type-path
-lib/ansible/modules/database/mongodb/mongodb_shard.py use-argspec-type-path
-lib/ansible/modules/database/mongodb/mongodb_user.py use-argspec-type-path
lib/ansible/modules/files/acl.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/files/assemble.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/files/blockinfile.py validate-modules:doc-choices-do-not-match-spec