summaryrefslogtreecommitdiffstats
path: root/pillar
diff options
context:
space:
mode:
authorGeorg Pfuetzenreuter2023-01-30 05:43:53 +0100
committerGeorg Pfuetzenreuter2023-01-30 05:43:53 +0100
commitba6522ce5b0c2a4f851fe4826aa9f077a4d3d381 (patch)
treebfe9255230804bb93f39886aef60d5e44993cf50 /pillar
parent096bb24769cb2eb692b1fccd67ab40d091c88d0f (diff)
downloadsalt-ba6522ce5b0c2a4f851fe4826aa9f077a4d3d381.tar.gz
salt-ba6522ce5b0c2a4f851fe4826aa9f077a4d3d381.tar.bz2
salt-ba6522ce5b0c2a4f851fe4826aa9f077a4d3d381.zip
Refactor map/macro sourcing
- move pillar macros and map to base directory - move listener logic from macro to map - update includes respectively Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
Diffstat (limited to 'pillar')
-rw-r--r--pillar/global/init.sls2
-rw-r--r--pillar/global/ssh.sls2
-rw-r--r--pillar/macros.jinja (renamed from pillar/global/macros.jinja)0
-rw-r--r--pillar/map.jinja (renamed from pillar/global/map.jinja)24
4 files changed, 25 insertions, 3 deletions
diff --git a/pillar/global/init.sls b/pillar/global/init.sls
index 16ab652..5b174bf 100644
--- a/pillar/global/init.sls
+++ b/pillar/global/init.sls
@@ -1,4 +1,4 @@
-{%- from slspath ~ '/map.jinja' import firewall_interfaces, public, internal, backend %}
+{%- from slspath ~ '/../map.jinja' import firewall_interfaces, public, internal, backend %}
include:
- role.salt.common
diff --git a/pillar/global/ssh.sls b/pillar/global/ssh.sls
index 8c18a86..57ef933 100644
--- a/pillar/global/ssh.sls
+++ b/pillar/global/ssh.sls
@@ -1,4 +1,4 @@
-{%- from slspath ~ '/../global/macros.jinja' import listeners -%}
+{%- from slspath ~ '/../map.jinja' import listeners -%}
{#-
{%- from '/tmp/salt-libertacasa/pillar/global/macros.jinja' import listeners with context -%}
#}
diff --git a/pillar/global/macros.jinja b/pillar/macros.jinja
index 1d3eade..1d3eade 100644
--- a/pillar/global/macros.jinja
+++ b/pillar/macros.jinja
diff --git a/pillar/global/map.jinja b/pillar/map.jinja
index c0fff69..bb0a536 100644
--- a/pillar/global/map.jinja
+++ b/pillar/map.jinja
@@ -1,7 +1,29 @@
-{%- from slspath ~ '/macros.jinja' import firewall_interfaces -%}
+{%- from 'macros.jinja' import firewall_interfaces, listeners -%}
{%- set firewall_interfaces = firewall_interfaces -%}
+{%- set listeners = listeners -%}
{%- set minion = grains['id'] -%}
+{#- START Listener detection logic -#}
+
+{%- set listen_ips = [] -%}
+{%- set minion = grains['id'] -%}
+{%- set legal6s = ('fd29', '2a01:4f8:11e:2200') -%}
+{%- set ip4s = salt.saltutil.runner('mine.get', tgt=minion, fun='network.ip_addrs', tgt_type='glob') -%}
+{%- set ip6s = salt.saltutil.runner('mine.get', tgt=minion, fun='network.ip_addrs6', tgt_type='glob') -%}
+{%- if minion in ip4s -%}{%- for ip in ip4s[minion] -%}
+{%- if salt['network.is_private'](ip) -%}
+{%- do listen_ips.append(ip) -%}
+{%- endif -%}
+{%- endfor -%}{%- endif -%}
+{%- if minion in ip6s -%}{%- for ip in ip6s[minion] -%}
+{%- if ip.startswith(legal6s) -%}
+{%- do listen_ips.append(ip) -%}
+{%- endif -%}
+{%- endfor -%}{%- endif -%}
+
+{#- END Listener detection logic -%}
+
+
{#- START Interface mapping logic -#}
{%- set public = [] -%}