Allow configure systemd

Change-Id: I54bc92902137899834408732ab852fd96d3f5a53
diff --git a/README.rst b/README.rst
index e6d251b..afad3df 100644
--- a/README.rst
+++ b/README.rst
@@ -291,6 +291,23 @@
           "cs_CZ.UTF-8 UTF-8":
             enabled: true
 
+Systemd settings:
+
+.. code-block:: yaml
+
+    linux:
+      system:
+        ...
+        systemd:
+          system:
+            Manager:
+              DefaultLimitNOFILE: 307200
+              DefaultLimitNPROC: 307200
+          user:
+            Manager:
+              DefaultLimitCPU: 2
+              DefaultLimitNPROC: 4
+
 Kernel
 ~~~~~~
 
diff --git a/linux/files/systemd.conf b/linux/files/systemd.conf
new file mode 100644
index 0000000..36e01a5
--- /dev/null
+++ b/linux/files/systemd.conf
@@ -0,0 +1,7 @@
+{%- from "linux/map.jinja" import system with context -%}
+{%- for section, options in settings.iteritems() -%}
+[{{ section }}]
+{%- for option, value in options.iteritems() %}
+{{ option }}={{ value }}
+{%- endfor -%}
+{%- endfor -%}
diff --git a/linux/system/init.sls b/linux/system/init.sls
index 5855bf5..13f1565 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -83,3 +83,6 @@
 {%- if system.service is defined %}
 - linux.system.service
 {%- endif %}
+{%- if system.systemd is defined %}
+- linux.system.systemd
+{%- endif %}
diff --git a/linux/system/systemd.sls b/linux/system/systemd.sls
new file mode 100644
index 0000000..d5377f1
--- /dev/null
+++ b/linux/system/systemd.sls
@@ -0,0 +1,34 @@
+{%- from "linux/map.jinja" import system with context %}
+{%- if system.enabled and grains.get('init', None) == 'systemd' %}
+
+{%- if system.systemd.system is defined %}
+linux_systemd_system_config:
+  file.managed:
+    - name: /etc/systemd/system.conf.d/90-salt.conf
+    - source: salt://linux/files/systemd.conf
+    - template: jinja
+    - makedirs: True
+    - defaults:
+        settings: {{ system.systemd.system }}
+    - watch_in:
+      - module: linux_systemd_reload
+{%- endif %}
+
+{%- if system.systemd.user is defined %}
+linux_systemd_user_config:
+  file.managed:
+    - name: /etc/systemd/user.conf.d/90-salt.conf
+    - source: salt://linux/files/systemd.conf
+    - template: jinja
+    - makedirs: True
+    - defaults:
+        settings: {{ system.systemd.user }}
+    - watch_in:
+      - module: linux_systemd_reload
+{%- endif %}
+
+linux_systemd_reload:
+  module.wait:
+  - name: service.systemctl_reload
+
+{%- endif %}
\ No newline at end of file