Skip to content

Add node priority configuration#317

Open
Madias2222 wants to merge 12 commits intoitential:devfrom
Madias2222:mongo_priority_single
Open

Add node priority configuration#317
Madias2222 wants to merge 12 commits intoitential:devfrom
Madias2222:mongo_priority_single

Conversation

@Madias2222
Copy link
Copy Markdown
Contributor

  • Add node priority configuration
  • Add new tag to permit reconfigure the priority at anytime.


# Preferred primary member for MongoDB replica sets.
# Leave empty to use the first host in the mongodb inventory group.
mongodb_preferred_primary: ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting the default to empty, why not default it to the first server in the list? So something like:

Suggested change
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Debug replication state
- name: Print replication state

register: mongodb_state
vars:
ansible_python_interpreter: "{{ mongodb_python_venv }}/bin/python3"
tags: reconfigure_priority
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need this tag. And if it is needed, I'm not sure it's name appropriately.

Comment on lines +115 to +116
that:
- mongodb_preferred_primary_resolved | bool
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registered variables should be prefixed by the role name.

Suggested change
register: reconfig_result
register: mongodb_reconfig_result

@kvelarde-itential
Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants