diff --git a/elk_metrics_6x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 b/elk_metrics_6x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 index 732acae4..49324b97 100644 --- a/elk_metrics_6x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 +++ b/elk_metrics_6x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 @@ -11,7 +11,9 @@ ############################# Heartbeat ###################################### {% set icmp_hosts = [] %} {% for host_item in groups['all'] %} -{% set _ = icmp_hosts.extend([hostvars[host_item]['ansible_host']]) %} +{% if hostvars[host_item]['ansible_host'] is defined %} +{% set _ = icmp_hosts.extend([hostvars[host_item]['ansible_host']]) %} +{% endif %} {% endfor %} # Configure monitors heartbeat.monitors: @@ -28,7 +30,7 @@ heartbeat.monitors: schedule: '@every 30s' # every 30 seconds from start of beat # List of hosts to ping - hosts: {{ icmp_hosts | to_json }} + hosts: {{ (icmp_hosts | default([])) | to_json }} # Configure IP protocol types to ping on if hostnames are configured. # Ping all resolvable IPs if `mode` is `all`, or only one IP if `mode` is `any`. ipv4: true @@ -103,7 +105,7 @@ heartbeat.monitors: # Using `tls`/`ssl`, an SSL connection is established. If no ssl is configured, # system defaults will be used (not supported on windows). # If `port` is missing in url, the ports setting is required. - hosts: {{ hosts | to_json }} + hosts: {{ (hosts | default([])) | to_json }} # Configure IP protocol types to ping on if hostnames are configured. # Ping all resolvable IPs if `mode` is `all`, or only one IP if `mode` is `any`. @@ -169,7 +171,7 @@ heartbeat.monitors: schedule: '@every 60s' # every 30 seconds from start of beat # Configure URLs to ping - urls: {{ hosts | to_json }} + urls: {{ (hosts | default([])) | to_json }} # Configure IP protocol types to ping on if hostnames are configured. # Ping all resolvable IPs if `mode` is `all`, or only one IP if `mode` is `any`. diff --git a/elk_metrics_6x/templates/_macros.j2 b/elk_metrics_6x/templates/_macros.j2 index c53d2709..ee8a4466 100644 --- a/elk_metrics_6x/templates/_macros.j2 +++ b/elk_metrics_6x/templates/_macros.j2 @@ -8,7 +8,7 @@ output.elasticsearch: # Scheme and port can be left out and will be set to the default (http and 9200) # In case you specify and additional path, the scheme is required: http://localhost:9200/path # IPv6 addresses should always be defined as: https://[2001:db8::1]:9200 - hosts: {{ data_hosts | to_json }} + hosts: {{ (data_hosts | default([])) | to_json }} # Set gzip compression level. compression_level: 3 @@ -99,7 +99,7 @@ output.logstash: enabled: true # The Logstash hosts - hosts: {{ data_hosts | to_json }} + hosts: {{ (data_hosts | default([])) | to_json }} # Number of workers per Logstash host. worker: 1 @@ -393,7 +393,7 @@ xpack.monitoring.elasticsearch: # Scheme and port can be left out and will be set to the default (http and 9200) # In case you specify and additional path, the scheme is required: http://localhost:9200/path # IPv6 addresses should always be defined as: https://[2001:db8::1]:9200 - hosts: {{ data_hosts | to_json }} + hosts: {{ (data_hosts | default([])) | to_json }} # Set gzip compression level. compression_level: 9