Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/mongodb_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ all:
To add an arbiter to the replica set, define a `mongodb_arbiter` group. Arbiters participate in
elections but hold no data.

An existing data-bearing member cannot be converted to an arbiter by re-running the playbook.
MongoDB does not allow `arbiterOnly` to change in a reconfig, so the run fails at "Create or
reconfigure the replicaset". Remove the member with `rs.remove()`, delete its data directory,
restart `mongod`, and re-add it with `rs.addArb()`, or use a host that is not yet in the replica set.

```yaml
all:
children:
Expand Down
3 changes: 2 additions & 1 deletion roles/mongodb/tasks/configure-mongodb-replicaset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
- name: Add the arbiter to the list of servers when there is one
ansible.builtin.set_fact:
mongodb_servers: >-
{{ mongodb_servers + [{'host': item + ':' + (mongodb_port | string), 'priority': 0}] }}
{{ mongodb_servers + [{'host': item + ':' + (mongodb_port | string),
'priority': 0, 'arbiterOnly': true}] }}
loop: "{{ groups.mongodb_arbiter }}"
when:
- mongodb_is_primary_node
Expand Down
Loading