Skip to content

Instantly share code, notes, and snippets.

@kafecho
Created January 19, 2016 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kafecho/465c4f7e4a4f506d0ba8 to your computer and use it in GitHub Desktop.
Save kafecho/465c4f7e4a4f506d0ba8 to your computer and use it in GitHub Desktop.
Ansible steps to setup the CouchDB 2.x cluster after CouchDB 2.xhas been installed
# The steps below are not necessary if an admin account as been created and port and bind address are already configured
# I already do this via Ansible
#- name: enable the cluster
# uri: HEADER_Content-Type="application/json" user=admin password=password force_basic_auth=yes method=POST url=http://127.0.0.1:5984/_cluster_setup body='{"action":"enable_cluster"}'
# when: inventory_hostname == "{{ groups.couches[0] }}"
# tags: enable_cluster
# ignore_errors: yes
# Register all the nodes that are part of the couches inventory group.
# Registration is done from the 1st node in that group.
- name: add nodes to the cluster
uri: status_code=201,409 HEADER_Content-Type="application/json" user=admin password=password force_basic_auth=yes method=POST url=http://127.0.0.1:5984/_cluster_setup body='{"action":"add_node","username":"admin","password":"password","host":"{{ item }}","port":5984}'
with_items: groups['couches']
when: inventory_hostname == "{{ groups.couches[0] }}" and inventory_hostname != item
tags: add_nodes
- name: finish the cluster
uri: status_code=201 HEADER_Content-Type="application/json" user=admin password=password force_basic_auth=yes method=POST url=http://127.0.0.1:5984/_cluster_setup body='{"action":"finish_cluster"}'
tags: finish_cluster
when: inventory_hostname == "{{ groups.couches[0] }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment