Skip to content

Commit

Permalink
Fixed problem with concurrency race
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Antipov committed Apr 17, 2016
1 parent b387a16 commit 77c55d5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ 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 mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
# Idempotence test
- >
Expand Down
27 changes: 23 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
and mongodb_user_admin_check.rc != 0 )
tags: [mongodb]

- name: create normal users
- name: create normal users with replicaset
mongodb_user:
database: "{{ item.database }}"
name: "{{ item.name }}"
Expand All @@ -51,13 +51,32 @@
roles: "{{ item.roles }}"
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
login_port: "{{ mongodb_net_port }}"
login_database: "admin"
login_port: "{{ mongodb_login_port|default(27017) }}"
login_host: "{{ mongodb_login_host|default('localhost') }}"
with_items:
- "{{ mongodb_users | default([]) }}"
when: mongodb_security_authorization == 'enabled'
when: ( mongodb_replication_replset
and mongodb_replication_replset != ''
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
tags: [mongodb]

- name: create normal users without replicaset
mongodb_user:
database: "{{ item.database }}"
name: "{{ item.name }}"
password: "{{ item.password }}"
update_password: "{{ mongodb_user_update_password }}"
roles: "{{ item.roles }}"
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
login_port: "{{ mongodb_net_port }}"
with_items:
- "{{ mongodb_users | default([]) }}"
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '') )
tags: [mongodb]

- name: Include MMS Agent configuration
include: mms-agent.yml
Expand Down
4 changes: 2 additions & 2 deletions tests/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ localhost ansible_connection=local ansible_python_interpreter=python2
[mongo_master]
mongo1 ansible_connection=docker ansible_python_interpreter=python2

[mongo_slave]
[mongo_replicas]
mongo2 ansible_connection=docker ansible_python_interpreter=python2
mongo3 ansible_connection=docker ansible_python_interpreter=python2

[mongo:children]
mongo_master
mongo_slave
mongo_replicas
11 changes: 9 additions & 2 deletions tests/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@
gather_facts: yes
roles:
- role: greendayonfire.mongodb
when: "'mongo' in group_names"

when: "'mongo_master' in group_names"

- hosts: "{{ target }}"
become: no
gather_facts: yes
roles:
- role: greendayonfire.mongodb
when: "'mongo_replicas' in group_names"

0 comments on commit 77c55d5

Please sign in to comment.