diff --git a/elk_metrics_6x/installHeartbeat.yml b/elk_metrics_6x/installHeartbeat.yml index bfc335c4..4a4cf0bd 100644 --- a/elk_metrics_6x/installHeartbeat.yml +++ b/elk_metrics_6x/installHeartbeat.yml @@ -1,6 +1,22 @@ --- + +- name: Set heartbeat host deployment group + hosts: kibana + gather_facts: false + connection: local + tasks: + - name: Add hosts to dynamic inventory group + group_by: + key: heatbeat_deployment_targets + parents: kibana + when: + - inventory_hostname in groups['kibana'][:3] + + tags: + - always + - name: Install Heartbeat - hosts: utility_all + hosts: heatbeat_deployment_targets become: true vars: haproxy_ssl: false diff --git a/elk_metrics_6x/setupHeartbeat.yml b/elk_metrics_6x/setupHeartbeat.yml index e26301a8..4c7be4a7 100644 --- a/elk_metrics_6x/setupHeartbeat.yml +++ b/elk_metrics_6x/setupHeartbeat.yml @@ -1,7 +1,7 @@ --- - name: Load Heartbeat Dashboards - hosts: utility_all[0] + hosts: kibana[0] gather_facts: false vars_files: - vars/variables.yml diff --git a/elk_metrics_6x/templates/heartbeat.yml.j2 b/elk_metrics_6x/templates/heartbeat.yml.j2 index 07b619ef..07b168b5 100644 --- a/elk_metrics_6x/templates/heartbeat.yml.j2 +++ b/elk_metrics_6x/templates/heartbeat.yml.j2 @@ -65,16 +65,15 @@ heartbeat.monitors: #fields_under_root: false {% for item in heartbeat_services %} -{% if inventory_hostname in groups['utility_all'] | default([]) %} -{% if item.type == 'tcp' %} -{% set hosts = [] %} -{% for port in item.ports | default([]) %} -{% for backend in item.group | default([]) %} -{% set backend_host = hostvars[backend]['ansible_host'] %} -{% set _ = hosts.extend([backend_host + ":" + (port | string)]) %} -{% endfor %} +{% if item.type == 'tcp' %} +{% set hosts = [] %} +{% for port in item.ports | default([]) %} +{% for backend in item.group | default([]) %} +{% set backend_host = hostvars[backend]['ansible_host'] %} +{% set _ = hosts.extend([backend_host + ":" + (port | string)]) %} {% endfor %} -{% if hosts | length > 0 %} +{% endfor %} +{% if hosts | length > 0 %} - type: tcp # monitor type `tcp`. Connect via TCP and optionally verify endpoint # by sending/receiving a custom payload @@ -147,16 +146,16 @@ heartbeat.monitors: # Required TLS protocols #supported_protocols: ["TLSv1.0", "TLSv1.1", "TLSv1.2"] -{% endif %} -{% elif item.type == 'http' %} -{% set hosts = [] %} -{% for port in item.ports | default([]) %} -{% for backend in item.group | default([]) %} -{% set backend_host = hostvars[backend]['ansible_host'] %} -{% set _ = hosts.extend(["http://" + backend_host + ":" + (port | string) + item.path]) %} -{% endfor %} +{% endif %} +{% elif item.type == 'http' %} +{% set hosts = [] %} +{% for port in item.ports | default([]) %} +{% for backend in item.group | default([]) %} +{% set backend_host = hostvars[backend]['ansible_host'] %} +{% set _ = hosts.extend(["http://" + backend_host + ":" + (port | string) + item.path]) %} {% endfor %} -{% if hosts | length > 0 %} +{% endfor %} +{% if hosts | length > 0 %} - type: http # monitor type `http`. Connect via HTTP an optionally verify response # Monitor name used for job name and document type @@ -217,7 +216,7 @@ heartbeat.monitors: #body: # Expected response settings -{% if item.check_response is defined %} +{% if item.check_response is defined %} check.response: {{ item.check_response }} #check.response: # Expected status code. If not configured or set to 0 any status code not @@ -229,7 +228,6 @@ heartbeat.monitors: # Required response contents. #body: -{% endif %} {% endif %} {% endif %} {% endif %} diff --git a/elk_metrics_6x/vars/variables.yml b/elk_metrics_6x/vars/variables.yml index 25e85064..f8d900e6 100644 --- a/elk_metrics_6x/vars/variables.yml +++ b/elk_metrics_6x/vars/variables.yml @@ -44,7 +44,7 @@ elastic_beat_retention_policy_hosts: apm: "{{ groups['apm-server'] | default([null]) | length }}" auditbeat: "{{ groups['hosts'] | default([null]) | length }}" filebeat: "{{ groups['hosts'] | default([null]) | length }}" - heartbeat: "{{ groups['utility_all'] | default([null]) | length }}" + heartbeat: "{{ groups['kibana'][:3] | default([null]) | length }}" journalbeat: "{{ groups['all'] | default([null]) | length }}" metricbeat: "{{ groups['all'] | default([null]) | length }}" packetbeat: "{{ groups['hosts'] | default([null]) | length }}"