Salt-mine remote_check support fixed
diff --git a/collectd/client.sls b/collectd/client.sls
index f092dcc..5937f04 100644
--- a/collectd/client.sls
+++ b/collectd/client.sls
@@ -71,6 +71,22 @@
{%- endif %}
{%- endfor %}
+{%- set remote_plugin = {} %}
+
+{%- if client.remote_collector %}
+
+{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
+
+{%- if node_grains.collectd is defined %}
+
+{%- set remote_plugin = salt['grains.filter_by']({'default': remote_plugin}, merge=node_grains.collectd.get('remote_plugin', {})) %}
+
+{%- endif %}
+
+{%- endfor %}
+
+{%- endif %}
+
collectd_client_grain:
file.managed:
- name: /etc/salt/grains.d/collectd
@@ -94,7 +110,7 @@
{%- for plugin_name, plugin in service_grains.collectd.local_plugin.iteritems() %}
-{%- plugin.get('plugin', 'native') not in ['python'] %}
+{%- if plugin.get('plugin', 'native') not in ['python'] %}
{{ client.config_dir }}/{{ plugin_name }}.conf:
file.managed:
@@ -121,9 +137,9 @@
{%- if client.remote_collector %}
-{%- for plugin_name, plugin in service_grains.collectd.local_plugin.iteritems() %}
+{%- for plugin_name, plugin in remote_plugin.iteritems() %}
-{%- plugin.get('plugin', 'native') not in ['python'] %}
+{%- if plugin.get('plugin', 'native') not in ['python'] %}
{{ client.config_dir }}/{{ plugin_name }}.conf:
file.managed:
@@ -175,7 +191,8 @@
- group: root
- mode: 660
- defaults:
- plugin: {{ service_grains.collectd.local_plugin|yaml }}
+ local_plugin: {{ service_grains.collectd.local_plugin|yaml }}
+ remote_plugin: {{ remote_plugin|yaml }}
- watch_in:
- service: collectd_service
- require:
@@ -220,6 +237,7 @@
- mode: 640
- defaults:
service_grains: {{ service_grains|yaml }}
+ remote_plugin: {{ remote_plugin|yaml }}
- require:
- file: collectd_client_conf_dir
- require_in:
diff --git a/collectd/files/collectd.conf b/collectd/files/collectd.conf
index 6e2394e..8c28563 100644
--- a/collectd/files/collectd.conf
+++ b/collectd/files/collectd.conf
@@ -887,7 +887,7 @@
{%- endif %}
{%- endfor %}
{%- if client.remote_collector %}
-{%- for plugin_name, plugin in service_grains.collectd.remote_plugin.iteritems() %}
+{%- for plugin_name, plugin in remote_plugin.iteritems() %}
{%- if plugin.get('plugin', 'native') not in ['python'] %}
{%- endif %}
{%- endfor %}
diff --git a/collectd/files/collectd_python.conf b/collectd/files/collectd_python.conf
index 9111065..7a279e7 100644
--- a/collectd/files/collectd_python.conf
+++ b/collectd/files/collectd_python.conf
@@ -1,3 +1,4 @@
+{%- from "collectd/map.jinja" import client with context -%}
<LoadPlugin python>
Globals false
</LoadPlugin>