Skip to content

Commit d0bacd7

Browse files
committed
Split replication configuration without auth to fix first run ansible
on all hosts in MongoDB cluster in same time.
1 parent 1fa78ca commit d0bacd7

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tasks/replication.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
with_items:
2020
- "{{ mongodb_replication_params|default([]) }}"
2121

22-
- name: Replication configuration without auth
22+
- name: Replication configuration without auth on master
2323
mongodb_replication:
2424
build_indexes: "{{ item.build_indexes|default(omit) }}"
2525
login_host: "{{ mongodb_login_host|default('localhost') }}"
@@ -32,6 +32,26 @@
3232
priority: "{{ item.priority|default(1.0) }}"
3333
votes: "{{ item.votes|default(omit) }}"
3434
ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}"
35-
when: mongodb_security_authorization == 'disabled'
35+
when: ( mongodb_security_authorization == 'disabled'
36+
and mongodb_master is defined and mongodb_master )
3637
with_items:
3738
- "{{ mongodb_replication_params|default([]) }}"
39+
40+
- name: Replication configuration without auth on replicas and arbiters
41+
mongodb_replication:
42+
build_indexes: "{{ item.build_indexes|default(omit) }}"
43+
login_host: "{{ mongodb_login_host|default('localhost') }}"
44+
login_port: "{{ mongodb_login_port|default(27017) }}"
45+
replica_set: "{{ mongodb_replication_replset }}"
46+
host_name: "{{ item.host_name }}"
47+
host_port: "{{ item.host_port|default(27017) }}"
48+
host_type: "{{ item.host_type|default('replica') }}"
49+
hidden: "{{ item.hidden|default(false) }}"
50+
priority: "{{ item.priority|default(1.0) }}"
51+
votes: "{{ item.votes|default(omit) }}"
52+
ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}"
53+
when: ( mongodb_security_authorization == 'disabled'
54+
and ( mongodb_master is not defined or not mongodb_master) )
55+
with_items:
56+
- "{{ mongodb_replication_params|default([]) }}"
57+

0 commit comments

Comments
 (0)