From 7e53b549e4962ff0387e155adcfc307d16ff1277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 17 Apr 2021 17:57:45 +0200 Subject: relayd: Use macros for shorter template --- templates/macros.j2 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 templates/macros.j2 (limited to 'templates') diff --git a/templates/macros.j2 b/templates/macros.j2 new file mode 100644 index 0000000..e2aad96 --- /dev/null +++ b/templates/macros.j2 @@ -0,0 +1,15 @@ +{% macro loop_hosts(group) -%} +{% for h in groups[group] -%} +{% set h = dict(hostvars[h]) %} +{{ caller(h) }} +{%- endfor %} +{%- endmacro %} + +{% macro loop_valid_hosts(group) -%} +{% for h in groups[group] -%} +{% set h = dict(hostvars[h]) %} +{% if h.ip.in is defined and h.ip.out is defined -%} +{{ caller(h) }} +{%- endif %} +{%- endfor %} +{%- endmacro %} -- cgit v1.2.3