Fix generation and use of grains
Change-Id: I93c253f2e8e33abc245c464d13fb255c8fdd5a6d
diff --git a/heka/_service.sls b/heka/_service.sls
index 18bfc0b..dfe3dbe 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -168,6 +168,23 @@
{%- endif %}
{%- endfor %}
+{%- if service_name in ('remote_collector', 'aggregator') %}
+
+{# Load the other services' support metadata from salt-mine #}
+
+{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
+{%- if node_grains.heka is defined %}
+{% for service, data in node_grains.heka.items() %}
+ {%- if service in ('remote_collector', 'aggregator') %}
+ {%- do salt['grains.filter_by']({'default': service_grains[service]}, merge=data) %}
+ {%- endif %}
+{% endfor %}
+{% endif %}
+{%- endfor %}
+
+{%- endif %}
+
+{# Overriding aggregated metadata from user-space pillar data #}
{%- for service_grain_name, service_grain in service_grains.iteritems() %}
{% if salt['pillar.get']('heka:'+service_grain_name) %}
diff --git a/heka/meta/salt.yml b/heka/meta/salt.yml
index 53b7f8d..f7c7af4 100644
--- a/heka/meta/salt.yml
+++ b/heka/meta/salt.yml
@@ -1,5 +1,4 @@
grain:
- heka:
{# Setup basic structure for all roles so updates can apply #}
{%- set service_grains = {
'log_collector': {
@@ -60,7 +59,9 @@
{%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge=heka_yaml) %}
{%- endif %}
{%- endfor %}
- {{ service_grains|yaml(False)|indent(4) }}
+ heka:
+ heka:
+ {{ salt['heka_alarming.grains_for_mine'](service_grains)|yaml(False)|indent(6) }}
{#-
vim: syntax=jinja