Skip to content

define replicaSet priority for each host? #38

@blair-anson

Description

@blair-anson

Is is possible to define the replicaSet priorities for each host?
The problem I have is that the host that runs the rs.initiate() command often does not become the Primary instance in the set. So running rs.reconfig() fails.
Ideally it would be great to define it as part of mongodb_conf_replSet

The playbook I'm running...

- hosts: localhost

  vars_files:
     - ./variables.yml

  roles:
    - { role: Stouts.mongodb }

  vars:
    mongodb_version: "3.2.12"
    mongodb_conf_auth: no
    mongodb_conf_dbpath: /data/db
    mongodb_conf_port: 27017
    mongodb_conf_bind_ip: 0.0.0.0
    mongodb_conf_replSet: rs0/{{ replicaSecondHost }}:27017,{{ replicaThirdHost }}:27017
    mongodb_shell:
      local:
        - rs.initiate()
        - cfg = rs.conf()
        - cfg.members[2].priority = 0
        - rs.reconfig(cfg)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions