diff options
author | Georg Pfuetzenreuter | 2023-01-30 05:43:53 +0100 |
---|---|---|
committer | Georg Pfuetzenreuter | 2023-01-30 05:43:53 +0100 |
commit | ba6522ce5b0c2a4f851fe4826aa9f077a4d3d381 (patch) | |
tree | bfe9255230804bb93f39886aef60d5e44993cf50 /pillar/macros.jinja | |
parent | 096bb24769cb2eb692b1fccd67ab40d091c88d0f (diff) | |
download | salt-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/macros.jinja')
-rw-r--r-- | pillar/macros.jinja | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pillar/macros.jinja b/pillar/macros.jinja new file mode 100644 index 0000000..1d3eade --- /dev/null +++ b/pillar/macros.jinja @@ -0,0 +1,26 @@ +{%- macro listeners() -%} +{%- 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 -%} +{%- for ip in listen_ips %} +- {{ ip }} +{%- endfor %} +{%- endmacro -%} + +{%- macro firewall_interfaces(interfaces) -%} +{%- if interfaces | length -%} +interfaces: {{ interfaces }} +{%- endif -%} +{%- endmacro -%} |