diff --git a/templates/etc_hosts.jinja2 b/templates/etc_hosts.jinja2
index e4201d9c76772f68642bd5420acc36984a5446ac..177f6ca78166dc1f09bd84383b5fa52473ae760f 100644
--- a/templates/etc_hosts.jinja2
+++ b/templates/etc_hosts.jinja2
@@ -46,9 +46,11 @@ ff02::2	  ip6-allrouters
 {% endif %}
 {% endfor %}
 
-{% for hostname, host in (commonauth_extras|default([])).iteritems() %}
+{% if commonauth_extras is defined %}
+{% for hostname, host in commonauth_extras.iteritems() %}
 {% if host.ip is defined %}
 {{ host.ip }} {{ hostname }}{% for alias in host.aliases|default([]) %} {{ alias }}{% endfor %}
 
 {% endif %}
 {% endfor %}
+{% endif %}