Skip to content

Commit 77c55d5

Browse files
author
Sergei Antipov
committed
Fixed problem with concurrency race
1 parent b387a16 commit 77c55d5

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ script:
6666

6767
# Test 3
6868
- >
69-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo
69+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo
7070
-e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
7171
# Idempotence test
7272
- >

tasks/main.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
and mongodb_user_admin_check.rc != 0 )
4343
tags: [mongodb]
4444

45-
- name: create normal users
45+
- name: create normal users with replicaset
4646
mongodb_user:
4747
database: "{{ item.database }}"
4848
name: "{{ item.name }}"
@@ -51,13 +51,32 @@
5151
roles: "{{ item.roles }}"
5252
login_user: "{{ mongodb_user_admin_name }}"
5353
login_password: "{{ mongodb_user_admin_password }}"
54-
login_port: "{{ mongodb_net_port }}"
55-
login_database: "admin"
54+
login_port: "{{ mongodb_login_port|default(27017) }}"
55+
login_host: "{{ mongodb_login_host|default('localhost') }}"
5656
with_items:
5757
- "{{ mongodb_users | default([]) }}"
58-
when: mongodb_security_authorization == 'enabled'
58+
when: ( mongodb_replication_replset
59+
and mongodb_replication_replset != ''
60+
and mongodb_security_authorization == 'enabled'
61+
and mongodb_master is defined and mongodb_master )
5962
tags: [mongodb]
6063

64+
- name: create normal users without replicaset
65+
mongodb_user:
66+
database: "{{ item.database }}"
67+
name: "{{ item.name }}"
68+
password: "{{ item.password }}"
69+
update_password: "{{ mongodb_user_update_password }}"
70+
roles: "{{ item.roles }}"
71+
login_user: "{{ mongodb_user_admin_name }}"
72+
login_password: "{{ mongodb_user_admin_password }}"
73+
login_port: "{{ mongodb_net_port }}"
74+
with_items:
75+
- "{{ mongodb_users | default([]) }}"
76+
when: ( mongodb_security_authorization == 'enabled'
77+
and (not mongodb_replication_replset
78+
or mongodb_replication_replset == '') )
79+
tags: [mongodb]
6180

6281
- name: Include MMS Agent configuration
6382
include: mms-agent.yml

tests/hosts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ localhost ansible_connection=local ansible_python_interpreter=python2
44
[mongo_master]
55
mongo1 ansible_connection=docker ansible_python_interpreter=python2
66

7-
[mongo_slave]
7+
[mongo_replicas]
88
mongo2 ansible_connection=docker ansible_python_interpreter=python2
99
mongo3 ansible_connection=docker ansible_python_interpreter=python2
1010

1111
[mongo:children]
1212
mongo_master
13-
mongo_slave
13+
mongo_replicas

tests/site.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,12 @@
2121
gather_facts: yes
2222
roles:
2323
- role: greendayonfire.mongodb
24-
when: "'mongo' in group_names"
25-
24+
when: "'mongo_master' in group_names"
25+
26+
- hosts: "{{ target }}"
27+
become: no
28+
gather_facts: yes
29+
roles:
30+
- role: greendayonfire.mongodb
31+
when: "'mongo_replicas' in group_names"
32+

0 commit comments

Comments
 (0)