From 8c82dbf3e44a563ed957ba2c15abdfa18d27642e Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Sun, 28 Jun 2020 00:58:00 +0200 Subject: [PATCH] only add hostname if external_ip is defined --- templates/ssh.config.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/ssh.config.j2 b/templates/ssh.config.j2 index 6fafa7a..77ce8a7 100644 --- a/templates/ssh.config.j2 +++ b/templates/ssh.config.j2 @@ -1,4 +1,6 @@ {% for hostname in groups.vms %} Host {{hostname}} +{% if 'external_ip' in hostvars[hostname] %} HostName {{hostvars[hostname].external_ip}} +{% endif %} {% endfor %}