diff --git a/ansible/roles/neutron/templates/l3_agent.ini.j2 b/ansible/roles/neutron/templates/l3_agent.ini.j2
index 679730f20e..c869fbc775 100644
--- a/ansible/roles/neutron/templates/l3_agent.ini.j2
+++ b/ansible/roles/neutron/templates/l3_agent.ini.j2
@@ -1,11 +1,11 @@
 #jinja2: trim_blocks: False
 [DEFAULT]
 {% if enable_neutron_dvr | bool %}
-    {% if inventory_hostname in groups['network'] %}
+{% if inventory_hostname in groups['network'] %}
 agent_mode = dvr_snat
-    {% elif inventory_hostname in groups['compute'] %}
+{% elif inventory_hostname in groups['compute'] %}
 agent_mode = dvr
-    {% endif %}
+{% endif %}
 {% else %}
 agent_mode = legacy
 {% endif %}