diff --git a/ansible/roles/vm_set/library/vm_topology.py b/ansible/roles/vm_set/library/vm_topology.py
index dfffde24483..c18a94a25c3 100644
--- a/ansible/roles/vm_set/library/vm_topology.py
+++ b/ansible/roles/vm_set/library/vm_topology.py
@@ -234,7 +234,7 @@ def init(self, vm_set_name, vm_base, duts_fp_ports, duts_name, ptf_exists=True,
self.pid = None
self.VMs = {}
- if 'VMs' in self.topo:
+ if 'VMs' in self.topo and len(self.topo['VMs']) > 0:
self.vm_base = vm_base
if vm_base in self.vm_names:
self.vm_base_index = self.vm_names.index(vm_base)
diff --git a/ansible/templates/minigraph_dpg.j2 b/ansible/templates/minigraph_dpg.j2
index 0c2352010f0..6fd4d00fb71 100644
--- a/ansible/templates/minigraph_dpg.j2
+++ b/ansible/templates/minigraph_dpg.j2
@@ -280,8 +280,6 @@
EverflowV6
{% if enable_data_plane_acl|default('true')|bool and vm_topo_config['topo_type'] != 'wan' %}
-
-
{%- set acl_intfs = [] -%}
{%- for index in range(vms_number) %}
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
@@ -297,6 +295,9 @@
{% endif %}
{% endif %}
{% endfor -%}
+{%- if acl_intfs | length > 0 -%}
+
+
{{- acl_intfs|join(';') -}}
DataAcl
@@ -304,6 +305,7 @@
{% endif %}
{% endif %}
+{% endif %}
{% endif %}