Commit b797b47f by Feanil Patel

Merge pull request #2449 from edx/feanil/mongo_3_0_role_update

Feanil/mongo 3 0 role update
parents 5e7227e8 8d91b529
......@@ -12,9 +12,9 @@
register: mongodb_already_installed
when: MONGO_CLUSTERED
- name: verify MongoDB not installed (clustered upgrades)
fail: msg="MongoDB is currently installed and cannot be safely upgraded in a clustered configuration. FIXME"
when: mongodb_already_installed.stat.exists and MONGO_CLUSTERED
#- name: verify MongoDB not installed (clustered upgrades)
# fail: msg="MongoDB is currently installed and cannot be safely upgraded in a clustered configuration. FIXME"
# when: mongodb_already_installed.stat.exists and MONGO_CLUSTERED
- name: remove mongo 2.4 if present
apt: >
......@@ -190,6 +190,19 @@
file: path=/tmp/repset_add_secondaries.js state=absent
when: MONGO_CLUSTERED and MONGO_PRIMARY == ansible_default_ipv4["address"]
- name: ensure all members are in replica set
mongo_rs_member:
rs_host: "{{ MONGO_PRIMARY }}"
rs_port: 27017
host: "{{ ansible_default_ipv4['address'] }}"
port: 27017
username: "{{ MONGO_ADMIN_USER }}"
password: "{{ MONGO_ADMIN_PASSWORD }}"
state: "{{ item.state }}"
hidden: "{{ item.hidden }}"
with_items: mongo_cluster_members
when: item.name == ansible_default_ipv4["address"]
- name: create a mongodb user
mongodb_user: >
database={{ item.database }}
......
......@@ -20,7 +20,7 @@ db.auth( '{{ MONGO_ADMIN_USER }}', '{{ MONGO_ADMIN_PASSWORD }}');
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- set hosts = mongo_cluster_members -%}
{%- set hosts = mongo_cluster_members|map(attribute="name") -%}
{%- endif -%}
// Check that the cluster is ok
......@@ -30,7 +30,7 @@ if(!rs.status().ok) { throw 'Mongo Cluster Not Ok';}
// and add them if we are the master
if(rs.isMaster().ismaster) {
if(rs.status().members.length!={{ hosts|length }}) {
{% for host in mongo_cluster_members %}
{% for host in hosts %}
{%- if host != ansible_default_ipv4["address"] -%}
rs.add({_id: {{ loop.index }}, host: '{{ host }}'});
{%- endif -%}
......
......@@ -22,11 +22,11 @@ db.auth( '{{ MONGO_ADMIN_USER }}', '{{ MONGO_ADMIN_PASSWORD }}');
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- set hosts = mongo_cluster_members -%}
{%- set hosts = mongo_cluster_members|map(attribute="name") -%}
{%- endif -%}
config = {_id: '{{ mongo_repl_set }}', members: [{% for host in mongo_cluster_members %}
config = {_id: '{{ mongo_repl_set }}', members: [{% for host in hosts %}
{%- if host == ansible_default_ipv4["address"] -%}
{_id: {{ loop.index }}, host: '{{ host }}'}
{%- endif -%}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment