aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/mongodb/templates/bootstrap_cluster.js.j2
blob: 05ea1c655ad01021028ab3448ee1bb8aefb0d147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
printjson(rs.initiate(
  {
    "_id" : "{{ mongodb_replication_set_name }}",
    "version" : 1,
    "members" : [
      {% for host in groups["mongodb"] %}
      {
        "_id" : {{ loop.index }},
        "host" : "{{ hostvars[host]['ansible_' + storage_interface]['ipv4']['address'] }}:{{ mongodb_port }}"
      }{% if not loop.last %},{% endif %}
      {% endfor %}
    ]
  }
))