Skip to content

Instantly share code, notes, and snippets.

@stelcheck
Created October 7, 2013 11:50
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 stelcheck/6866552 to your computer and use it in GitHub Desktop.
Save stelcheck/6866552 to your computer and use it in GitHub Desktop.
set_fact or shell?
- name: If undefined set bootstrap to the first node of the cluster
set_fact:
bootstrap: "{{ groups[cluster_name]|first }}"
when: bootstrap == False or bootstrap is not defined
tags:
- couchbase
- bootstrap
- name: Check if the current machine is part of the cluster
shell: >
{{ couchbase_cmd }} server-list \
-c {{ hostvars[bootstrap]['ansible_' + private_interface]['ipv4']['address'] }}:8091 \
-u {{ admin_user }} \
-p {{ admin_password }} \
| grep {{ hostvars[inventory_hostname]['ansible_' + private_interface]['ipv4']['address'] }}
ignore_errors: True
register: is_member
tags:
- couchbase
- bootstrap
- name: Add nodes to the cluster
shell: >
{{ couchbase_cmd }} server-add \
-c {{ hostvars[bootstrap]['ansible_' + private_interface]['ipv4']['address'] }}:8091 \
-u {{ admin_user }} \
-p {{ admin_password }} \
--server-add={{ hostvars[inventory_hostname]['ansible_' + private_interface]['ipv4']['address'] }}:8091 \
--server-add-username={{ admin_user }} \
--server-add-password={{ admin_password }}
when: is_member.rc != 0
notify:
- Rebalance the cluster
tags:
- couchbase
- bootstrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment