Created
July 7, 2022 21:16
-
-
Save shadyrudy/c01ee2253c9a59bef0b95e8b85f0fb2e to your computer and use it in GitHub Desktop.
A j2 file for initilzing a MongoDB replica set. Needs an ansible inventory lists of hosts to work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rs.initiate( | |
{ | |
_id: "{{ group_names[0] }}", | |
members: [ | |
{% for h in groups[group_names[0] ]%} | |
{ _id: {{ loop.index }}, host : "{{ h }}": | |
{%if hostvars[inventory_hostname].group_names[0].startswith('shard') %} | |
{{ shard_port }} | |
{% else %} | |
{{ cfgserver_port }} | |
{% endif %}", | |
priority: 1 } {% if not loop.last %},{% endif %} | |
{% endfor %} | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment