summaryrefslogtreecommitdiffstats
path: root/pillar/global/map.jinja
blob: c0fff69b279d5c2ace6ed709c9f3ca01b522dbca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{%- from slspath ~ '/macros.jinja' import firewall_interfaces -%}
{%- set firewall_interfaces = firewall_interfaces -%}
{%- set minion = grains['id'] -%}

{#- START Interface mapping logic -#}

{%- set public = [] -%}
{%- set internal = [] -%}
{%- set backend = [] -%}

{%- set internal6s = ('2a01:4f8:11e:2200') -%}
{%- set backend6s = ('fd29:8e45:f292:ff80') -%}
{#- to-do: get rid of illegal backend4s -#}
{%- set backend4s = ('172.168.100') -%}
{%- set excluded_interfaces = ('lo') -%}
{%- set interfaces = salt.saltutil.runner('mine.get', tgt=minion, fun='network.interfaces', tgt_type='glob') -%}

{%- if minion in interfaces -%}{%- for interface, ifconfig in interfaces[minion].items() -%}
{%- if not interface.startswith(excluded_interfaces) -%}

{%- if 'inet' in ifconfig -%}
{%- for inetconf in ifconfig['inet'] -%}
{%- set ip4 = inetconf['address'] -%}

{%- if salt['network.is_private'](ip4) -%}

{%- if not interface in internal -%}
{%- do internal.append(interface) -%}
{%- endif -%}

{%- elif ip4.startswith(backend4s) -%}

{%- if not interface in backend -%}
{%- do backend.append(interface) -%}
{%- endif -%}

{%- else -%}

{%- if not interface in public -%}
{%- do public.append(interface) -%}
{%- endif -%}

{%- endif %}

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

{%- if 'inet6' in ifconfig -%}
{%- for inet6conf in ifconfig['inet6'] -%}
{%- set ip6 = inet6conf['address'] -%}

{%- if ip6.startswith(internal6s) -%}

{%- if not interface in internal -%}
{%- do internal.append(interface) -%}
{%- endif -%}

{%- elif ip6.startswith(backend6s) -%}

{%- if not interface in backend -%}
{%- do backend.append(interface) -%}
{%- endif -%}

{%- endif -%}

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

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

{#- END Interface mapping logic -#}