Conversation
Madias2222
commented
Mar 31, 2026
- Add node priority configuration
- Add new tag to permit reconfigure the priority at anytime.
Removed unnecessary 'become: true' directives from various tasks in the configure-mongodb-numa.yml file.
|
|
||
| # Preferred primary member for MongoDB replica sets. | ||
| # Leave empty to use the first host in the mongodb inventory group. | ||
| mongodb_preferred_primary: "" |
There was a problem hiding this comment.
Instead of setting the default to empty, why not default it to the first server in the list? So something like:
| mongodb_preferred_primary: "" | |
| mongodb_preferred_primary: "{{ groups.mongodb[0] }}" |
That way you don't have to write any code to set it.
| mongodb_servers: [] | ||
| when: not mongodb_state.replication_enabled | ||
| when: | ||
| - inventory_hostname in groups.mongodb |
There was a problem hiding this comment.
I don't think you need any of these when clauses. The role is only executed on mongodb hosts.
| - groups.mongodb_arbiter is defined | ||
| tags: reconfigure_priority | ||
|
|
||
| - name: Debug replication state |
There was a problem hiding this comment.
| - name: Debug replication state | |
| - name: Print replication state |
| register: mongodb_state | ||
| vars: | ||
| ansible_python_interpreter: "{{ mongodb_python_venv }}/bin/python3" | ||
| tags: reconfigure_priority |
There was a problem hiding this comment.
I'm not sure we need this tag. And if it is needed, I'm not sure it's name appropriately.
| that: | ||
| - mongodb_preferred_primary_resolved | bool |
There was a problem hiding this comment.
| that: | |
| - mongodb_preferred_primary_resolved | bool | |
| that: mongodb_preferred_primary_resolved | bool |
| that: | ||
| - mongodb_preferred_primary_resolved | bool | ||
| fail_msg: >- | ||
| mongodb_preferred_primary must match a host in groups.mongodb. |
There was a problem hiding this comment.
| mongodb_preferred_primary must match a host in groups.mongodb. | |
| mongodb_preferred_primary must match a host in groups.mongodb |
| replica_set: "{{ mongodb_replset_name }}" | ||
| reconfigure: true | ||
| validate: true | ||
| register: reconfig_result |
There was a problem hiding this comment.
Registered variables should be prefixed by the role name.
| register: reconfig_result | |
| register: mongodb_reconfig_result |
|
@Madias2222 @steven-schattenberg-itential There is a lot of code here just to handle figuring out the primary. What do you think about changing the group names to something like mongodb_primary, mongodb_secondary, etc, similar to the Redis role? |