csantanapr closed pull request #3030: attempt to fix couchdb clustering
URL: https://github.com/apache/incubator-openwhisk/pull/3030
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ansible/couchdb.yml b/ansible/couchdb.yml
index 70faba99db..807bd87a21 100644
--- a/ansible/couchdb.yml
+++ b/ansible/couchdb.yml
@@ -2,5 +2,6 @@
 # This playbook deploys a CouchDB for Openwhisk.  
 
 - hosts: db
+  serial: 1
   roles:
   - couchdb
\ No newline at end of file
diff --git a/ansible/environments/local/hosts b/ansible/environments/local/hosts
index 516340861a..31e502671d 100644
--- a/ansible/environments/local/hosts
+++ b/ansible/environments/local/hosts
@@ -23,7 +23,8 @@ invoker1            ansible_host=172.17.0.1 
ansible_connection=local
 
 ; db group is only used if db_provider is CouchDB
 [db]
-172.17.0.1          ansible_host=172.17.0.1 ansible_connection=local
+db0          ansible_host=172.17.0.1 ansible_connection=local
+db1          ansible_host=172.17.0.1 ansible_connection=local
 
 [redis]
 172.17.0.1          ansible_host=172.17.0.1 ansible_connection=local
diff --git a/ansible/roles/couchdb/tasks/deploy.yml 
b/ansible/roles/couchdb/tasks/deploy.yml
index 88ec1eb50b..3123604c87 100644
--- a/ansible/roles/couchdb/tasks/deploy.yml
+++ b/ansible/roles/couchdb/tasks/deploy.yml
@@ -4,6 +4,7 @@
 - name: "Set the coordinator to the first node"
   set_fact:
     coordinator: "{{ groups['db'][0] }}"
+    db_port: "{{ db_port|int + groups['db'].index(inventory_hostname) }}"
 
 - name: check if db credentials are valid for CouchDB
   fail: msg="The db provider in your {{ inventory_dir }}/group_vars/all is {{ 
db_provider }}, it has to be CouchDB, pls double check"
@@ -28,7 +29,7 @@
 
 - name: (re)start CouchDB
   docker_container:
-    name: couchdb
+    name: couchdb{{ groups['db'].index(inventory_hostname) }}
     image: apache/couchdb:{{ couchdb.version }}
     state: started
     recreate: true
@@ -36,8 +37,8 @@
     volumes: "{{volume_dir | default([])}}"
     ports:
       - "{{ db_port }}:5984"
-      - "4369:4369"
-      - "9100:9100"
+      - "{{ 4369 + groups['db'].index(inventory_hostname) }}:4369"
+      - "{{ 9100 + groups['db'].index(inventory_hostname) }}:9100"
     env:
       COUCHDB_USER: "{{ db_username }}"
       COUCHDB_PASSWORD: "{{ db_password }}"
@@ -62,11 +63,11 @@
     user: "{{ db_username }}"
     password: "{{ db_password }}"
     force_basic_auth: yes
-  when: inventory_hostname == coordinator
+  when: (inventory_hostname == coordinator) and (db.instances|int >= 2) 
 
 - name: add remote nodes to the cluster
   uri:
-    url: "{{ db_protocol }}://{{ coordinator }}:{{ db_port }}/_cluster_setup"
+    url: "{{ db_protocol }}://{{ hostvars[groups['db'] | first].ansible_host 
}}:{{ db_port }}/_cluster_setup"
     method: POST
     body: >
         {"action": "add_node", "host":"{{ ansible_host }}", "port": {{ db_port 
}}, "username": "{{ db_username }}", "password":"{{ db_password }}"}
@@ -75,7 +76,7 @@
     user: "{{ db_username }}"
     password: "{{ db_password }}"
     force_basic_auth: yes
-  when: inventory_hostname != coordinator
+  when: (inventory_hostname != coordinator) and (db.instances|int >= 2)
 
 - name: finish the cluster setup mode
   uri:
@@ -88,7 +89,7 @@
     user: "{{ db_username }}"
     password: "{{ db_password }}"
     force_basic_auth: yes
-  when: inventory_hostname == coordinator
+  when: (inventory_hostname == coordinator) and (db.instances|int >= 2)
 
 - name: disable reduce limit on views
   uri:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to