add service management support
Change-Id: Iffb55fee41b8398de12554b58a9d36ae2b81e7ff
diff --git a/README.rst b/README.rst
index 97420bc..a0a415a 100644
--- a/README.rst
+++ b/README.rst
@@ -601,6 +601,21 @@
printf "This is [company name] network.\n"
printf "Unauthorized access strictly prohibited.\n"
+Services
+~~~~~~~~
+
+Stop and disable linux service:
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ service:
+ apt-daily.timer:
+ status: dead
+
+Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
+
RHEL / CentOS
^^^^^^^^^^^^^
diff --git a/linux/system/init.sls b/linux/system/init.sls
index 3961bca..5855bf5 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -80,3 +80,6 @@
{%- if system.netconsole is defined %}
- linux.system.netconsole
{%- endif %}
+{%- if system.service is defined %}
+- linux.system.service
+{%- endif %}
diff --git a/linux/system/service.sls b/linux/system/service.sls
new file mode 100644
index 0000000..869760d
--- /dev/null
+++ b/linux/system/service.sls
@@ -0,0 +1,16 @@
+{%- from "linux/map.jinja" import system with context %}
+{%- if system.enabled %}
+
+{%- for name, service in system.service.iteritems() %}
+
+linux_service_{{ name }}:
+ service.{{ service.status }}:
+ {%- if service.status == 'dead' %}
+ - enable: {{ service.get('enabled', False) }}
+ {%- elif service.status == 'running' %}
+ - enable: {{ service.get('enabled', True) }}
+ {%- endif %}
+ - name: {{ name }}
+
+{%- endfor %}
+{%- endif %}