Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support composable Hostmetadata #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion zabbix/files/default/etc/zabbix/zabbix_agentd.conf.jinja
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
Expand Down