Merge pull request #5 from salt-formulas/support

Allow deploying logrotate jobs using support meta
diff --git a/README.rst b/README.rst
index 22d952f..ad9cdbb 100644
--- a/README.rst
+++ b/README.rst
@@ -52,6 +52,31 @@
               - compress
               - postrotate: "reload rsyslog >/dev/null 2>&1 || true"
 
+Cross-formula relationship
+==========================
+
+It's possible to use support meta to define logrotate rules from within other
+formula.
+
+Example ``meta/logrotate.yml`` for horizon formula:
+
+.. code-block:: yaml
+
+    job:
+      horizon:
+        - files:
+            - /var/log/horizon/*.log
+          options:
+            - compress
+            - delaycompress
+            - missingok
+            - notifempty
+            - rotate: 10
+            - daily
+            - minsize: 20M
+            - maxsize: 500M
+            - postrotate: "if /etc/init.d/apache2 status > /dev/null; then /etc/init.d/apache2 reload > /dev/null; fi"
+
 Reference
 =========
 
diff --git a/logrotate/server.sls b/logrotate/server.sls
index 6d66dfc..18dd045 100644
--- a/logrotate/server.sls
+++ b/logrotate/server.sls
@@ -6,7 +6,18 @@
   pkg.installed:
     - names: {{ server.pkgs }}
 
-{%- for name, job in server.job.iteritems() %}
+{%- set _jobs = server.get('job', {}) %}
+{%- for service_name, service in pillar.items() %}
+  {%- set support_fragment_file = service_name+'/meta/logrotate.yml' %}
+  {%- macro load_support_file() %}{% include support_fragment_file ignore missing %}{% endmacro %}
+  {%- set support_yaml = load_support_file()|load_yaml %}
+
+  {%- if support_yaml and support_yaml.get('job', {}) %}
+    {%- do _jobs.update(support_yaml.get('job', {})) %}
+  {%- endif %}
+{%- endfor %}
+
+{%- for name, job in _jobs.iteritems() %}
 
 logrotate_job_{{ name }}:
   file.managed: