Skip to content

Commit da21130

Browse files
committed
Update the deployment script for CouchDB.
1 parent 3fbe947 commit da21130

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

ansible/roles/couchdb/tasks/deploy.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
- name: set the coordinator to the first node
2121
set_fact:
22-
coordinator: "{{ groups['db'][0] }}"
22+
coordinator: "{{ couchdb_coordinator | default(groups['db'][0]) }}"
2323

2424
- name: "Set the volumes"
2525
set_fact:
@@ -49,13 +49,26 @@
4949
volumes: "{{ volumes }} + [ '{{ db.persist_path }}:/opt/couchdb/data' ]"
5050
when: db.persist_path
5151

52-
- include_tasks: gen_erl_cookie.yml
53-
when: (db.instances|int >= 2)
54-
55-
- name: "set the erlang cookie volume"
52+
- name: "mount conf directory for db configuration"
5653
set_fact:
57-
volumes: "{{ volumes }} + [ '{{ config_root_dir }}/erlang.cookie:/opt/couchdb/.erlang.cookie' ]"
58-
when: (db.instances|int >= 2)
54+
volumes: "{{ volumes }} + [ '{{ db_confdir }}:/opt/couchdb/etc' ]"
55+
when: db_confdir is defined
56+
57+
- name: ensure CouchDB config directory exists
58+
file:
59+
path: "{{ db_confdir }}"
60+
state: directory
61+
become: "{{ db.dir.become }}"
62+
when: db_confdir is defined
63+
64+
- name: synchronize default configuration files from local to remote in CouchDB config directory
65+
synchronize:
66+
src: "files/"
67+
dest: "{{ db_confdir }}"
68+
delete: yes
69+
recursive: yes
70+
become: "{{ db.dir.become }}"
71+
when: db_confdir is defined
5972

6073
- name: "(re)start CouchDB from '{{ couchdb_image }} ' "
6174
vars:
@@ -115,7 +128,7 @@
115128
password: "{{ db.credentials.admin.pass }}"
116129
force_basic_auth: yes
117130
register: cluster_state
118-
run_once: true
131+
delegate_to: "{{ coordinator }}"
119132

120133
- name: check clustered nodes
121134
uri:
@@ -126,7 +139,7 @@
126139
password: "{{ db.credentials.admin.pass }}"
127140
force_basic_auth: yes
128141
register: nodes_state
129-
run_once: true
142+
delegate_to: "{{ coordinator }}"
130143

131144
- name: generates couchdb node name
132145
set_fact:
@@ -184,3 +197,13 @@
184197
force_basic_auth: yes
185198
when: (inventory_hostname == coordinator) and (db.instances|int >= 2) and (cluster_state.json.state != "cluster_finished")
186199

200+
- name: check whether the cluster is setup or not
201+
uri:
202+
url: "{{ db.protocol }}://{{ ansible_host }}:{{ db.port }}/_cluster_setup"
203+
method: GET
204+
status_code: 200
205+
user: "{{ db.credentials.admin.user }}"
206+
password: "{{ db.credentials.admin.pass }}"
207+
force_basic_auth: yes
208+
register: cluster_state
209+
run_once: true

0 commit comments

Comments
 (0)