Fix service name for xenial and newer distributions using netfilter
diff --git a/iptables/map.jinja b/iptables/map.jinja
index 9e9c115..2562cb2 100644
--- a/iptables/map.jinja
+++ b/iptables/map.jinja
@@ -2,10 +2,14 @@
{% set service = salt['grains.filter_by']({
'Debian': {
'pkgs': ['iptables','iptables-persistent' ],
- 'service': 'iptables-persistent',
+ 'service': 'netfilter-persistent',
},
'RedHat': {
'pkgs': ['iptables'],
'service': 'iptables',
},
-}, merge=salt['pillar.get']('iptables:service')) %}
+}, merge=salt['grains.filter_by']({
+ 'trusty': {
+ 'service': 'iptables-persistent',
+ },
+}, grain='oscodename', merge=salt['pillar.get']('iptables:service'))) %}
diff --git a/iptables/service.sls b/iptables/service.sls
index 75d47ef..c6b76f4 100644
--- a/iptables/service.sls
+++ b/iptables/service.sls
@@ -10,7 +10,11 @@
- names: {{ service.pkgs }}
iptables_services:
+{%- if grains.init == 'systemd' %}
+ service.running:
+{%- else %}
service.dead:
+{%- endif %}
- enable: true
- name: {{ service.service }}
- sig: test -e /etc/iptables/rules.v4