From d69770b7767cb3f65de00e19ef90a50ab81d66dd Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:25 -0400 Subject: [PATCH] Avoid writing hosts if empty --- roles/base/templates/etc/hosts.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/base/templates/etc/hosts.j2 b/roles/base/templates/etc/hosts.j2 index 1b0f6fa..9e579c1 100644 --- a/roles/base/templates/etc/hosts.j2 +++ b/roles/base/templates/etc/hosts.j2 @@ -12,7 +12,7 @@ ff02::2 ip6-allrouters {{ node.upstream_ip }} {{ node.hostname.split('.')[0] }}.{{ local_domain }} {% endfor %} -{% if hosts is defined %} +{% if hosts is defined and hosts %} {% for host in hosts %} {{ host.ip }} {{ host.name }} {% endfor %}