Sfoglia il codice sorgente

Allow setting iptables by support metadata

tags/2016.12
Filip Pytloun 8 anni fa
parent
commit
8e8389246f
2 ha cambiato i file con 16 aggiunte e 1 eliminazioni
  1. +1
    -1
      iptables/_rule.sls
  2. +15
    -0
      iptables/rules.sls

+ 1
- 1
iptables/_rule.sls Vedi File

@@ -6,7 +6,7 @@ iptables_{{ chain_name }}_{{ rule_name }}:
iptables.append:
{%- if loop.index != 1 %}
- require:
- iptables: iptables_{{ chain_name }}_{{ loop.index - 1 }}
- iptables: iptables_{{ chain_name }}_{% if service_name is defined %}{{ service_name }}_{% endif %}{{ loop.index - 1 }}
{%- endif %}
{%- endif %}
- table: {{ rule.get('table', 'filter') }}

+ 15
- 0
iptables/rules.sls Vedi File

@@ -10,6 +10,21 @@ iptables_{{ chain_name }}_policy:
- table: filter
{%- endif %}

{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('iptables', {}).get('enabled', False) %}

{%- set grains_fragment_file = service_name+'/meta/iptables.yml' %}
{%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
{%- set grains_yaml = load_grains_file()|load_yaml %}

{%- for rule in grains_yaml.iptables.rules %}
{%- set rule_name = service_name+'_'+loop.index|string %}
{% include "iptables/_rule.sls" %}
{%- endfor %}

{%- endif %}
{%- endfor %}

{%- for rule in chain.get('rules', []) %}
{%- set rule_name = loop.index %}
{% include "iptables/_rule.sls" %}

Loading…
Annulla
Salva