Georg Pfuetzenreuter
bd7fe25eb0
All checks were successful
ci/lysergic/push/pipeline Pipeline was successful
Don't fail if mine does not contain information about the queried minion. In the future it would be nice to add another conditional to allow such minions to fall-back to the locally executed network module for masterless setups. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
21 lines
759 B
Django/Jinja
21 lines
759 B
Django/Jinja
{%- 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 -%}
|