aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-04-17 17:57:45 +0200
committerRomain Gonçalves <me@rgoncalves.se>2021-04-17 17:57:45 +0200
commit7e53b549e4962ff0387e155adcfc307d16ff1277 (patch)
tree4cd054e469db01c3e0f53eefe59588a3674d25b0 /templates
parent24edb45881ac7a469f0c3fdcda6fd26edb199120 (diff)
downloadinfrastructure-7e53b549e4962ff0387e155adcfc307d16ff1277.tar.gz
relayd: Use macros for shorter template
Diffstat (limited to 'templates')
-rw-r--r--templates/macros.j215
1 files changed, 15 insertions, 0 deletions
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 %}
remember that computers suck.