Commit 2b5be722 authored by Ross McDonald's avatar Ross McDonald
Browse files

Updated clustering logic to add 3+ nodes. Added a few more checks to ensure...

Updated clustering logic to add 3+ nodes. Added a few more checks to ensure clustering is successful (and fail if not).
parent b270c56c
......@@ -48,4 +48,19 @@
- name: Display output
debug:
var: influxdb_show_servers_output
\ No newline at end of file
var: influxdb_show_servers_output
- name: Assert clustering status (local/vagrant)
assert:
that:
- "influxdb_show_servers_output.stdout.find(item)"
with_items: groups['all']
when: is_vagrant
- name: Assert clustering status (non-local)
assert:
that:
- "influxdb_show_servers_output.stdout.find(item)"
with_items: groups['influxdb']|default([], True)
when: "'influxdb' in groups and is_vagrant == False"
\ No newline at end of file
......@@ -31,20 +31,20 @@
state: started
enabled: yes
register: influxdb_started
when: influxdb_start_service == True
when: influxdb_start_service
- name: Pause to ensure InfluxDB service is up
pause:
seconds: 3
when: influxdb_started.changed and influxdb_start_service == True
when: influxdb_started.changed and influxdb_start_service
- name: Collect service status
command: service influxdb status
register: influxdb_service_status
when: influxdb_start_service == True
when: influxdb_start_service
- name: Assert status of InfluxDB service
assert:
that:
- "influxdb_service_status.rc == 0"
when: influxdb_start_service == True
\ No newline at end of file
when: influxdb_start_service
\ No newline at end of file
......@@ -7,8 +7,8 @@
- include: cluster.yml
tags: [influxdb, cluster]
when: influxdb_cluster_servers
when: influxdb_cluster_servers and influxdb_start_service
- include: demo.yml
tags: [influxdb, demo]
when: influxdb_load_sample_data and influxdb_http_auth_enabled == "false"
when: influxdb_load_sample_data and influxdb_http_auth_enabled == "false" and influxdb_start_service
INFLUXD_OPTS="-hostname {{ ansible_hostname }}{% if influxdb_cluster_servers %} -join {% if is_vagrant %}{% for host in groups['all']|sort %}{% if hostvars[host]['ansible_hostname'] != ansible_hostname %}{{ hostvars[host]['ansible_hostname'] }}:{{ influxdb_meta_port }}{% if not loop.last %},{% endif %}{% endif %}{% endfor %}{% endif %}{% if not is_vagrant %}{% for host in groups['influxdb']|sort %}{% if hostvars[host]['ansible_hostname'] != ansible_hostname %}{{ hostvars[host]['ansible_hostname'] }}:{{ influxdb_meta_port }}{% if not loop.last %},{% endif %}{% endif %}{% endfor %}{% endif %}{% endif %}"
INFLUXD_OPTS="-hostname {{ ansible_hostname }}{% if influxdb_cluster_servers %} -join {% if is_vagrant %}{% for host in groups['all'] if hostvars[host]['ansible_hostname'] != ansible_hostname %}{% if not loop.index > 3 %}{{ hostvars[host]['ansible_hostname'] }}:{{ influxdb_meta_port }}{% if not loop.index > 3 and not loop.last %},{% endif %}{% endif %}{% endfor %}{% endif %}{% if not is_vagrant %}{% for host in groups['influxdb'] if hostvars[host]['ansible_hostname'] != ansible_hostname %}{% if not loop.index > 3 %}{{ hostvars[host]['ansible_hostname'] }}:{{ influxdb_meta_port }}{% if not loop.index > 3 and not loop.last %},{% endif %}{% endif %}{% endfor %}{% endif %}{% endif %}"
......@@ -3,11 +3,6 @@
- defaults/main.yml
- vars/main.yml
tasks:
- name: Add all hosts to influxdb group
add_host:
name: "{{ ansible_hostname }}"
groups: influxdb
- include: tasks/main.yml
handlers:
- include: handlers/main.yml
......@@ -4,4 +4,4 @@
is_vagrant: no
# Whether or not to purge peer data on each run (useful for cluster testing)
influxdb_purge_peer_data: yes
\ No newline at end of file
influxdb_purge_peer_data: no
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment