Exposed heartbeat monitor list

Currently heartbeat will be configured to ping every host in the
inventory on its 'ansible_host' interface when deployed. This commit
allows this host list to be overridden using the heartbeat_icmp_hosts
variable to avoid e.g. monitoring connections between different
networks. The default monitor list has also been changed from 'all' to
the heartbeat deployment hosts.

Change-Id: Icb3688e4a2f87ac29df142973f21b96b2686f935
This commit is contained in:
Duncan Martin Walker 2020-02-24 16:23:37 +00:00
parent 9bf0c1d03a
commit f8ed35e3d6
2 changed files with 8 additions and 3 deletions

View File

@ -32,3 +32,7 @@ processors: {}
# Logging level
# Available log levels are error, warning, info, debug
heartbeat_log_level: "{{ elastic_beat_log_level | default('info') }}"
# List of interfaces with which heartbeat tests connectivity.
# Defaults to ansible_host on all hosts in the inventory to which heartbeat is deployed
# heartbeat_icmp_hosts: "{{ groups['heartbeat'] | default(groups['heartbeat_deployment_targets']) | map('extract', hostvars, ['ansible_host']) | list }}"

View File

@ -9,12 +9,13 @@
# https://www.elastic.co/guide/en/beats/heartbeat/index.html
############################# Heartbeat ######################################
{% set icmp_hosts = [] %}
{% for host_item in groups['all'] %}
{% set _icmp_hosts = [] %}
{% for host_item in (groups['heartbeat'] | default(groups['heartbeat_deployment_targets'])) %}
{% if hostvars[host_item]['ansible_host'] is defined %}
{% set _ = icmp_hosts.extend([hostvars[host_item]['ansible_host']]) %}
{% set _ = _icmp_hosts.extend([hostvars[host_item]['ansible_host']]) %}
{% endif %}
{% endfor %}
{% set icmp_hosts = ( heartbeat_icmp_hosts | default(_icmp_hosts)) %}
# Define a directory to load monitor definitions from. Definitions take the form
# of individual yaml files.