Skip to content

Commit

Permalink
fix: move patch default rw concern after configure and auth_initializ…
Browse files Browse the repository at this point in the history
…ation, but before replication
  • Loading branch information
JonathanGun authored Dec 23, 2024
1 parent ffb02e4 commit fb4d4dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
8 changes: 0 additions & 8 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,5 @@
- wait when mongodb is started
when: mongodb_use_mongos

# patch known issue default rw concern
- name: Set default RW concern
community.mongodb.mongodb_shell:
login_user: "{{ mongodb_root_admin_name }}"
login_password: "{{ mongodb_root_admin_password }}"
eval: 'db.adminCommand({"setDefaultRWConcern": 1, "defaultWriteConcern": { "w": 1 }})'
when: mongodb_master

- name: Flush all handlers at this point
meta: flush_handlers
32 changes: 20 additions & 12 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@
include_tasks: configure.yml
tags: [mongodb]

- name: Include replication and auth configuration
include_tasks: replication_init_auth.yml
when: ( mongodb_replication_replset | length > 0
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
tags: [mongodb]

- name: Include replication configuration
include_tasks: replication.yml
when: mongodb_replication_replset | length > 0
tags: [mongodb]

- name: Check whether admin user is already exist
command: >
mongo --quiet {{ '--ssl --host ' + mongodb_net_ssl_host if mongodb_net_ssl_mode == 'requireSSL' else '' }} -u {{ mongodb_user_admin_name }} \
Expand All @@ -63,6 +51,26 @@
and mongodb_user_admin_check.rc != 0 )
tags: [mongodb]

# patch known issue default rw concern
- name: Set default read-write concern
ansible.builtin.command: "{{ 'mongosh' if mongodb_version.split('.')[0] | int >= 5 else 'mongo' }} -u {{ mongodb_root_admin_name }} -p {{ mongodb_root_admin_password }} --eval 'db.adminCommand({\"setDefaultRWConcern\": 1,\"defaultWriteConcern\": { \"w\": 1 }})'"
when: ( mongodb_security_authorization == 'enabled'
and not mongodb_replication_replset
and mongodb_master is defined and mongodb_master )
tags: [mongodb]

- name: Include replication and auth configuration
include_tasks: replication_init_auth.yml
when: ( mongodb_replication_replset | length > 0
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
tags: [mongodb]

- name: Include replication configuration
include_tasks: replication.yml
when: mongodb_replication_replset | length > 0
tags: [mongodb]

- name: create normal users with replicaset
mongodb_user:
database: "{{ item.database }}"
Expand Down

0 comments on commit fb4d4dc

Please sign in to comment.