Merge "Add require ifenslave before start configuring bonding interfaces."
diff --git a/README.rst b/README.rst
index 0db113f..ab091b8 100644
--- a/README.rst
+++ b/README.rst
@@ -1231,6 +1231,28 @@
apt-daily.timer:
status: dead
+Override systemd service unit:
+
+.. code-block:: yaml
+
+ parameters:
+
+ linux:
+ system:
+ service:
+ tgt:
+ name: tgt
+ status: running
+ enabled: True
+ override:
+ 50:
+ target: tgt.service.d
+ name: bind
+ content: |
+ [Service]
+ ExecStart=
+ ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
+
Possible statuses are ``dead`` (disable service by default), ``running``
(enable service by default), ``enabled``, ``disabled``:
diff --git a/_modules/net_checks.py b/_modules/net_checks.py
index cb0f4fc..bdfb4b8 100644
--- a/_modules/net_checks.py
+++ b/_modules/net_checks.py
@@ -39,7 +39,7 @@
nics = []
nics_list = listdir('/sys/class/net/')
for nic_name in nics_list:
- if research('(br|bond|ens|enp|eth|one|ten|fourty)[0-9]+', nic_name):
+ if research('(bond|ens|enp|eth|one|ten|fourty)[0-9]+|br.+', nic_name):
# Interface should be in "up" state in order to get carrier status
Popen("ip li set dev " + nic_name + " up", shell=True, stdout=PIPE)
diff --git a/linux/files/ovs_port b/linux/files/ovs_port
index 222ca8e..a55b821 100644
--- a/linux/files/ovs_port
+++ b/linux/files/ovs_port
@@ -14,3 +14,6 @@
{%- if port.ovs_options is defined %}
ovs_options {{ port.ovs_options }}
{%- endif %}
+{%- if port.hwaddress is defined %}
+hwaddress {{ port.hwaddress }}
+{%- endif %}
diff --git a/linux/system/service.sls b/linux/system/service.sls
index a6f9f02..a50ae36 100644
--- a/linux/system/service.sls
+++ b/linux/system/service.sls
@@ -1,16 +1,61 @@
{%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %}
-{%- for name, service in system.service.items() %}
+ {%- for name, service in system.service.items() %}
-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 }}
+ {%- if service.name is defined %}
+ {%- set service_name = service.name %}
+ {%- else %}
+ {%- set service_name = name %}
+ {%- endif %}
-{%- endfor %}
+ {%- if service.status == 'running' %}
+
+ {%- if grains.get('init', None) == 'systemd' %}
+ {%- if service.override is defined %}
+ {%- for order,rule in service.override.items() %}
+ {%- if rule.get('enabled', True) %}
+{{ service_name }}_{{ order }}_override:
+ file.managed:
+ - name: /etc/systemd/system/{{ rule.target }}/{{ order }}-{{ rule.name }}.conf
+ - contents_pillar: linux:system:service:{{ name }}:override:{{ order}}:content
+ - makedirs: True
+ - user: root
+ - group: root
+ - watch_in:
+ - module: {{ service_name }}_systemd_reload
+ - service: {{ service_name }}_service
+ {%- endif %}
+ {%- endfor %}
+
+{{ service_name }}_systemd_reload:
+ module.wait:
+ - name: service.systemctl_reload
+ - watch_in:
+ - service: {{ service_name }}_service
+
+{{ service_name }}_service:
+ service.running:
+ - name: {{ service_name }}
+ - enable: {{ service.get('enabled', True) }}
+ {%- if grains.get('noservices') %}
+ - onlyif: /bin/false
+ {%- endif %}
+ {%- endif %}
+ {%- endif %}
+
+ {%- elif service.status == 'dead' %}
+
+{{ service_name }}_service:
+ service.dead:
+ - name: {{ service_name }}
+ - enable: {{ service.get('enabled', False) }}
+ {%- if grains.get('noservices') %}
+ - onlyif: /bin/false
+ {%- endif %}
+
+ {%- endif %}
+
+ {%- endfor %}
+
{%- endif %}
diff --git a/tests/pillar/system.sls b/tests/pillar/system.sls
index 6a0b16b..3dc183d 100644
--- a/tests/pillar/system.sls
+++ b/tests/pillar/system.sls
@@ -24,6 +24,20 @@
domain: ci.local
environment: prd
purge_repos: true
+ service:
+ apt-daily.timer:
+ status: dead
+ tgt:
+ name: tgt
+ status: running
+ enabled: True
+ override:
+ 50:
+ target: tgt.service.d
+ content: |
+ [Service]
+ ExecStart=
+ ExecStart=/usr/sbin/tgtd -f --iscsi portal=127.0.0.1:5555
directory:
/tmp/test:
makedirs: true