Fixed problem with concurrency race

This commit is contained in:
Sergei Antipov 2016-04-17 23:18:31 +06:00
parent b387a16715
commit 77c55d557b
4 changed files with 35 additions and 9 deletions

View File

@ -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
- >

View File

@ -42,7 +42,26 @@
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 }}"
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_login_port|default(27017) }}"
login_host: "{{ mongodb_login_host|default('localhost') }}"
with_items:
- "{{ mongodb_users | default([]) }}"
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 }}"
@ -52,13 +71,13 @@
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
login_port: "{{ mongodb_net_port }}"
login_database: "admin"
with_items:
- "{{ mongodb_users | default([]) }}"
when: mongodb_security_authorization == 'enabled'
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
when: mongodb_mms_api_key != ""

View File

@ -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

View File

@ -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"