This is an automated email from the ASF dual-hosted git repository.
rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 321b3d9 Enable couchdb persist_path in a distributed environment as
well (#4290)
321b3d9 is described below
commit 321b3d9f74d9a5ac7913003721ef6493bf0db042
Author: Dominic Kim <[email protected]>
AuthorDate: Wed Apr 3 11:17:26 2019 +0900
Enable couchdb persist_path in a distributed environment as well (#4290)
* Skip clustering when nodes are already in the cluster
* Enable couchdb persist_path for a distributed environment as well
---
ansible/roles/couchdb/tasks/deploy.yml | 50 ++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 3 deletions(-)
diff --git a/ansible/roles/couchdb/tasks/deploy.yml
b/ansible/roles/couchdb/tasks/deploy.yml
index cf40cc1..9116e71 100644
--- a/ansible/roles/couchdb/tasks/deploy.yml
+++ b/ansible/roles/couchdb/tasks/deploy.yml
@@ -11,6 +11,10 @@
set_fact:
volumes: []
+- name: "Set the nodes"
+ set_fact:
+ couchdb_nodes: []
+
- name: check if db credentials are valid for CouchDB
fail: msg="The db provider in your {{ hosts_dir }}/group_vars/all is {{
db.provider }}, it has to be CouchDB, pls double check"
when: db.provider != "CouchDB"
@@ -88,6 +92,45 @@
force_basic_auth: yes
when: (create_users_db.status == 404) and (inventory_hostname ==
coordinator) and (couchdb.version is version_compare('2.0','>='))
+- name: check whether couchdb is clustered
+ uri:
+ url: "{{ db.protocol }}://{{ ansible_host }}:{{ db.port }}/_cluster_setup"
+ method: GET
+ status_code: 200
+ user: "{{ db.credentials.admin.user }}"
+ password: "{{ db.credentials.admin.pass }}"
+ force_basic_auth: yes
+ register: cluster_state
+ run_once: true
+
+- name: check clustered nodes
+ uri:
+ url: "{{ db.protocol }}://{{ ansible_host }}:{{ db.port }}/_membership"
+ method: GET
+ status_code: 200
+ user: "{{ db.credentials.admin.user }}"
+ password: "{{ db.credentials.admin.pass }}"
+ force_basic_auth: yes
+ register: nodes_state
+ run_once: true
+
+- name: generates couchdb node name
+ set_fact:
+ couchdb_nodes: "{{ couchdb_nodes }} + [ 'couchdb@{{ item }}' ]"
+ with_items: "{{ groups['db'] }}"
+ run_once: true
+
+- name: check if there is a new node
+ set_fact:
+ require_clustering: true
+ when: item not in nodes_state.json.cluster_nodes
+ with_items: "{{ couchdb_nodes }}"
+ run_once: true
+
+- name: set node name
+ set_fact:
+ node_name: "couchdb@{{ ansible_host }}"
+
- name: enable the cluster setup mode
uri:
url: "{{ db.protocol }}://{{ ansible_host }}:{{ db.port }}/_cluster_setup"
@@ -99,7 +142,7 @@
user: "{{ db.credentials.admin.user }}"
password: "{{ db.credentials.admin.pass }}"
force_basic_auth: yes
- when: (inventory_hostname == coordinator) and (db.instances|int >= 2)
+ when: (inventory_hostname == coordinator) and (db.instances|int >= 2) and
require_clustering is defined
- name: add remote nodes to the cluster
uri:
@@ -112,7 +155,7 @@
user: "{{ db.credentials.admin.user }}"
password: "{{ db.credentials.admin.pass }}"
force_basic_auth: yes
- when: (inventory_hostname != coordinator) and (db.instances|int >= 2)
+ when: (inventory_hostname != coordinator) and (db.instances|int >= 2) and
require_clustering is defined and node_name not in
nodes_state.json.cluster_nodes
- name: finish the cluster setup mode
uri:
@@ -125,4 +168,5 @@
user: "{{ db.credentials.admin.user }}"
password: "{{ db.credentials.admin.pass }}"
force_basic_auth: yes
- when: (inventory_hostname == coordinator) and (db.instances|int >= 2)
+ when: (inventory_hostname == coordinator) and (db.instances|int >= 2) and
(cluster_state.json.state != "cluster_finished")
+