diff --git a/zabbix/files/default/etc/zabbix/zabbix_agentd.conf.jinja b/zabbix/files/default/etc/zabbix/zabbix_agentd.conf.jinja index a71f338e..684dc64d 100644 --- a/zabbix/files/default/etc/zabbix/zabbix_agentd.conf.jinja +++ b/zabbix/files/default/etc/zabbix/zabbix_agentd.conf.jinja @@ -1,4 +1,17 @@ {% from "zabbix/map.jinja" import zabbix with context -%} +{# Consider a value, keep a string, join a list, or join a dict's sorted keys -#} +{% macro flexjoin(srcval, sep=' ') -%} + {# If it's a simple value, emit it. -#} + {% if srcval is string or srcval is number -%} + {{ srcval -}} + {# If it's a dict, take the keys (for pillar merging), sort them (for stability), flexjoin them. -#} + {% elif srcval is mapping -%} + {{ flexjoin( srcval.keys()|sort, sep) -}} + {# If it's a list, join it. -#} + {% else -%} + {{ srcval|join(sep) -}} + {% endif -%} +{% endmacro -%} {% set settings = salt['pillar.get']('zabbix-agent', {}) -%} # Managed by saltstack # do not edit this file. @@ -130,7 +143,7 @@ Hostname={{ settings.get('hostname', salt['grains.get']('id')) }} # An agent will issue an error and not start if the value is over limit of 255 characters. # If not defined, value will be acquired from HostMetadataItem. # -{% if settings.get('hostmetadata', false) %}HostMetadata={{ settings.get('hostmetadata') }}{% endif %} +{% if settings.get('hostmetadata', false) %}HostMetadata={{ flexjoin(settings.get('hostmetadata'), ' ') }}{% endif %} ### Option: HostMetadataItem # Optional parameter that defines an item used for getting host metadata.