Add support for systemd
Change-Id: I024f4906ed43771f5a569c00ba954bd56b82fcff
diff --git a/fluentd/agent.sls b/fluentd/agent.sls
index d1ed8d8..9fb4d86 100644
--- a/fluentd/agent.sls
+++ b/fluentd/agent.sls
@@ -47,6 +47,24 @@
- require:
- pkg: fluentd_packages_agent
+{%- if grains.get('init') == 'systemd' %}
+
+fluentd_config_service:
+ file.managed:
+ - name: /etc/systemd/system/td-agent.service.d/override.conf
+ - source: salt://fluentd/files/override.conf
+ - makedirs: true
+ - user: root
+ - group: root
+ - mode: 644
+ - template: jinja
+ - require:
+ - pkg: fluentd_packages_agent
+ - context:
+ fluentd_agent: {{ fluentd_agent }}
+
+{%- else %}
+
fluentd_config_service:
file.managed:
- name: /etc/default/td-agent
@@ -60,6 +78,8 @@
- context:
fluentd_agent: {{ fluentd_agent }}
+{%- endif %}
+
fluentd_config_agent:
file.managed:
- name: {{ fluentd_agent.dir.config }}/td-agent.conf
@@ -210,6 +230,7 @@
{%- endif %}
- watch:
- file: fluentd_config_agent
+ - file: fluentd_config_service
- require:
- file: fluentd_positiondb_dir
diff --git a/fluentd/files/override.conf b/fluentd/files/override.conf
new file mode 100644
index 0000000..c5fa878
--- /dev/null
+++ b/fluentd/files/override.conf
@@ -0,0 +1,3 @@
+[Service]
+User={{ fluentd_agent.get('user', 'root') }}
+Group={{ fluentd_agent.get('group', 'root') }}