-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds test case for issue * Move files to correct location * Fix variable name * Remove unneeded params * Run on arbiter * Add retry code * Longer delay * Try different command * Add new error code * Remove param * Add debug step * Add debug code * Use module.debug * Runs listDatabases cmd * Add Arbiter handling to auth function * Adds further test cases * Fix param indent * dummy * Add asserts to tests
- Loading branch information
1 parent
27d350a
commit 21ded18
Showing
4 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
tests/integration/targets/mongodb_status/tasks/651_auth.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Tests for issue 651 | ||
- vars: | ||
mongo_parameters: &mongo_parameters | ||
login_host: localhost | ||
login_port: 3003 # Run on Arbiter | ||
login_user: "{{ mongodb_admin_user }}" | ||
login_password: "{{ mongodb_admin_password }}" | ||
login_database: "admin" | ||
|
||
block: | ||
|
||
- set_fact: | ||
mongodb_nodes: | ||
- 3001 | ||
- 3002 | ||
- 3003 | ||
|
||
- set_fact: | ||
mongod_auth: true | ||
|
||
- set_fact: | ||
current_replicaset: "issue_651" | ||
|
||
- include_tasks: mongod_replicaset.yml | ||
|
||
- name: Create replicaset with module | ||
community.mongodb.mongodb_replicaset: | ||
login_host: localhost | ||
login_port: 3001 | ||
replica_set: "{{ current_replicaset }}" | ||
members: | ||
- localhost:3001 | ||
- localhost:3002 | ||
- localhost:3003 | ||
arbiter_at_index: 2 | ||
|
||
- name: Add mongodb admin user - rs0 | ||
community.mongodb.mongodb_user: | ||
login_host: localhost | ||
login_port: 3001 | ||
replica_set: '{{ current_replicaset }}' | ||
database: admin | ||
name: '{{ mongodb_admin_user }}' | ||
password: '{{ mongodb_admin_password }}' | ||
roles: | ||
- root | ||
state: present | ||
run_once: true | ||
|
||
- name: Get replica_set status | ||
community.mongodb.mongodb_status: | ||
<<: *mongo_parameters | ||
replica_set: "{{ current_replicaset }}" | ||
#auth_mechanism: "SCRAM-SHA-256" # Why is this here for no auth? | ||
poll: 6 | ||
interval: 10 | ||
register: replset_status | ||
|
||
- name: Validate expected number of PRIMARY, SECONDARY, ARBITER hosts | ||
assert: | ||
that: | ||
- "{{ replset_status['replicaset'].values() | list | length == 3 }}" | ||
- "{{ replset_status['replicaset'].values() | list | select('match', 'PRIMARY') | list | length == 1 }}" | ||
- "{{ replset_status['replicaset'].values() | list | select('match', 'SECONDARY') | list | length == 1 }}" | ||
- "{{ replset_status['replicaset'].values() | list | select('match', 'ARBITER') | list | length == 1 }}" |
50 changes: 50 additions & 0 deletions
50
tests/integration/targets/mongodb_status/tasks/651_noauth.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Tests for issue 651 | ||
- vars: | ||
mongo_parameters: &mongo_parameters | ||
login_host: localhost | ||
login_port: 3003 # Run on Arbiter | ||
login_database: "admin" | ||
|
||
block: | ||
|
||
- set_fact: | ||
mongodb_nodes: | ||
- 3001 | ||
- 3002 | ||
- 3003 | ||
|
||
- set_fact: | ||
mongod_auth: false | ||
|
||
- set_fact: | ||
current_replicaset: "issue_651" | ||
|
||
- include_tasks: mongod_replicaset.yml | ||
|
||
- name: Create replicaset with module | ||
community.mongodb.mongodb_replicaset: | ||
login_host: localhost | ||
login_port: 3001 | ||
replica_set: "{{ current_replicaset }}" | ||
members: | ||
- localhost:3001 | ||
- localhost:3002 | ||
- localhost:3003 | ||
arbiter_at_index: 2 | ||
|
||
- name: Get replica_set status | ||
community.mongodb.mongodb_status: | ||
<<: *mongo_parameters | ||
replica_set: "{{ current_replicaset }}" | ||
#auth_mechanism: "SCRAM-SHA-256" # Why is this here for no auth? | ||
poll: 6 | ||
interval: 10 | ||
register: replset_status | ||
|
||
- name: Validate expected number of PRIMARY, SECONDARY, ARBITER hosts | ||
assert: | ||
that: | ||
- "{{ replset_status['replicaset'].values() | list | length == 3 }}" | ||
- "{{ replset_status['replicaset'].values() | list | select('match', 'PRIMARY') | list | length == 1 }}" | ||
- "{{ replset_status['replicaset'].values() | list | select('match', 'SECONDARY') | list | length == 1 }}" | ||
- "{{ replset_status['replicaset'].values() | list | select('match', 'ARBITER') | list | length == 1 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters