blob: 3ca3e3e9a7afcbec3e0d9dab84566f36ae2cf076 [file] [log] [blame]
{% set agent = salt['grains.filter_by']({
'Debian': {
'pkgs': ['telegraf'],
'dir': {
'config': '/etc/telegraf',
'config_d': '/etc/telegraf/telegraf.d'
},
},
}, merge=salt['pillar.get']('telegraf:agent')) %}
{% set remote_agent = salt['grains.filter_by']({
'Debian': {
'dir': {
'config': '/srv/volumes/local/telegraf',
'config_d': '/srv/volumes/local/telegraf/telegraf.d'
},
},
}, merge=salt['pillar.get']('telegraf:remote_agent')) %}
{# Collect configuration from */meta/telegraf.yml #}
{%- set telegraf_grains = {'telegraf': {'agent': {'input': {}}, 'remote_agent': {'input':{}}}} %}
{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('telegraf', {}).get('enabled', False) %}
{%- set grains_fragment_file = service_name+'/meta/telegraf.yml' %}
{%- macro load_grains_file() %}{% include grains_fragment_file ignore missing %}{% endmacro %}
{%- set grains_yaml = load_grains_file()|load_yaml %}
{%- if grains_yaml is mapping %}
{%- set telegraf_grains = salt['grains.filter_by']({'default': telegraf_grains}, merge={'telegraf': grains_yaml}) %}
{%- endif %}
{%- endif %}
{%- endfor %}
{# Deep-merge the service configuration with the pillar data #}
{%- do salt['defaults.merge'](telegraf_grains, {'telegraf': {'agent': agent, 'remote_agent': remote_agent}}) %}