Skip to content

Commit afbf951

Browse files
author
Enver Cicak
committed
Fixed variable redefinition. Fixed typo in variable name
1 parent 24c3e19 commit afbf951

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

iptables/init.sls

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
{% from "iptables/map.jinja" import firewall with context %}
66
{% set install = firewall.install %}
77
{% set strict_mode = firewall.strict %}
8-
{% set ipv6 = firewall.get('ipv6', False) %}
98
{% set global_block_nomatch = firewall.block_nomatch %}
109
{% set packages = firewall.pkgs %}
1110
{% set ipv4 = 'IPv4' %}
1211
{% set ipv6 = 'IPv6' %}
1312
{% set protocols = [ipv4] %}
14-
{% if ipv6 %}
13+
{% if firewall.get('ipv6', False) %}
1514
{% do protocols.append(ipv6) %}
1615
{% endif %}
17-
{% set sufixes = {ipv4: '', ipv6: '_ipv6'} %}
16+
{% set suffixes = {ipv4: '', ipv6: '_ipv6'} %}
1817
1918
{%- if firewall.enabled %}
2019
{%- if install %}
@@ -31,7 +30,7 @@
3130
# If the firewall is set to strict mode, we'll need to allow some
3231
# that always need access to anything
3332
{%- for protocol in protocols %}
34-
iptables_allow_localhost{{sufixes[protocol]}}:
33+
iptables_allow_localhost{{suffixes[protocol]}}:
3534
iptables.append:
3635
- table: filter
3736
- chain: INPUT
@@ -45,7 +44,7 @@
4544
- save: True
4645
4746
# Allow related/established sessions
48-
iptables_allow_established{{sufixes[protocol]}}:
47+
iptables_allow_established{{suffixes[protocol]}}:
4948
iptables.append:
5049
- table: filter
5150
- chain: INPUT
@@ -58,7 +57,7 @@
5857
- save: True
5958
6059
# Set the policy to deny everything unless defined
61-
enable_reject_policy{{sufixes[protocol]}}:
60+
enable_reject_policy{{suffixes[protocol]}}:
6261
iptables.set_policy:
6362
- table: filter
6463
- chain: INPUT
@@ -67,14 +66,14 @@
6766
- family: ipv6
6867
{%- endif %}
6968
- require:
70-
- iptables: iptables_allow_localhost{{sufixes[protocol]}}
71-
- iptables: iptables_allow_established{{sufixes[protocol]}}
69+
- iptables: iptables_allow_localhost{{suffixes[protocol]}}
70+
- iptables: iptables_allow_established{{suffixes[protocol]}}
7271
{%- endfor %}
7372
{%- endif %}
7473
7574
# Generate ipsets for all services that we have information about
7675
{%- for protocol in protocols %}
77-
{%- for service_name, service_details in firewall.get('services' + sufixes[protocol], {}).items() %}
76+
{%- for service_name, service_details in firewall.get('services' + suffixes[protocol], {}).items() %}
7877
{% set block_nomatch = service_details.get('block_nomatch', False) %}
7978
{% set interfaces = service_details.get('interfaces','') %}
8079
{% set protos = service_details.get('protos',['tcp']) %}
@@ -88,7 +87,7 @@
8887
{%- for ip in service_details.get('ips_allow', ['0.0.0.0/0']) %}
8988
{%- if interfaces == '' %}
9089
{%- for proto in protos %}
91-
iptables_{{service_name}}_allow_{{ip}}_{{proto}}{{sufixes[protocol]}}:
90+
iptables_{{service_name}}_allow_{{ip}}_{{proto}}{{suffixes[protocol]}}:
9291
iptables.insert:
9392
- position: 1
9493
- table: filter
@@ -106,7 +105,7 @@
106105
{%- else %}
107106
{%- for interface in interfaces %}
108107
{%- for proto in protos %}
109-
iptables_{{service_name}}_allow_{{ip}}_{{proto}}_{{interface}}{{sufixes[protocol]}}:
108+
iptables_{{service_name}}_allow_{{ip}}_{{proto}}_{{interface}}{{suffixes[protocol]}}:
110109
iptables.insert:
111110
- position: 1
112111
- table: filter
@@ -130,7 +129,7 @@
130129
# If strict mode is disabled we may want to block anything else
131130
{%- if interfaces == '' %}
132131
{%- for proto in protos %}
133-
iptables_{{service_name}}_deny_other_{{proto}}{{sufixes[protocol]}}:
132+
iptables_{{service_name}}_deny_other_{{proto}}{{suffixes[protocol]}}:
134133
iptables.append:
135134
- position: last
136135
- table: filter
@@ -147,7 +146,7 @@
147146
{%- else %}
148147
{%- for interface in interfaces %}
149148
{%- for proto in protos %}
150-
iptables_{{service_name}}_deny_other_{{proto}}_{{interface}}{{sufixes[protocol]}}:
149+
iptables_{{service_name}}_deny_other_{{proto}}_{{interface}}{{suffixes[protocol]}}:
151150
iptables.append:
152151
- position: last
153152
- table: filter
@@ -191,7 +190,7 @@
191190
{%- for protocol in protocols %}
192191
{%- for service_name, service_details in firewall.get('whitelist', {}).items() %}
193192
{%- for ip in service_details.get('ips_allow', []) %}
194-
iptables_{{service_name}}_allow_{{ip}}{{sufixes[protocol]}}:
193+
iptables_{{service_name}}_allow_{{ip}}{{suffixes[protocol]}}:
195194
iptables.append:
196195
- table: filter
197196
- chain: INPUT

0 commit comments

Comments
 (0)