Skip to content

Commit

Permalink
Allow persisted couchdb directory mount.
Browse files Browse the repository at this point in the history
For example:
  wskdev couchdb -d -e"db_persist_path=/home/couchd/openwhisk"
  • Loading branch information
rabbah committed Feb 8, 2019
1 parent b2dd4a2 commit f0b1ed3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ db:
protocol: "{{ db_protocol | default(lookup('ini', 'db_protocol section=db_creds file={{ playbook_dir }}/db_local.ini')) }}"
port: "{{ db_port | default(lookup('ini', 'db_port section=db_creds file={{ playbook_dir }}/db_local.ini')) }}"
host: "{{ db_host | default(lookup('ini', 'db_host section=db_creds file={{ playbook_dir }}/db_local.ini')) }}"
persist_path: "{{ db_persist_path | default(false) }}"
instances: "{{ groups['db'] | length }}"
authkeys:
- guest
Expand Down
18 changes: 17 additions & 1 deletion ansible/roles/couchdb/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@
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"

- name: ensure directory for persisting db exists
stat:
path: "{{ db.persist_path }}"
register: db_persist_path_exists
when: db.persist_path

- name: fail if path to persist db does not exist
fail:
msg: directory for persisting db does not exist '{{ db.persist_path }}'
when: db.persist_path and not (db_persist_path_exists.stat.exists and db_persist_path_exists.stat.isdir)

- name: "mount directory for persisting dbs"
set_fact:
volumes: "{{ volumes }} + [ '{{ db.persist_path }}:/opt/couchdb/data' ]"
when: db.persist_path

- include_tasks: gen_erl_cookie.yml
when: (db.instances|int >= 2)

Expand Down Expand Up @@ -52,7 +68,7 @@
retries: 12
delay: 5

- name: create '_users' database for singleton mode
- name: create '_users' database for singleton mode if necessary
uri:
url: "{{ db.protocol }}://{{ ansible_host }}:{{ db.port }}/_users"
method: PUT
Expand Down

0 comments on commit f0b1ed3

Please sign in to comment.