Skip to content

Commit

Permalink
fix: move patch rw concern task between auth configuration and replic…
Browse files Browse the repository at this point in the history
…ation configuration
  • Loading branch information
JonathanGun authored Dec 23, 2024
1 parent fb4d4dc commit 9aeff6e
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
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]

# 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_replication_replset | length > 0
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 @@ -51,26 +70,6 @@
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 9aeff6e

Please sign in to comment.