diff --git a/salt/files/libvirt/domains/common.xml.j2 b/salt/files/libvirt/domains/common.xml.j2
index 548b6ec..ef58604 100644
--- a/salt/files/libvirt/domains/common.xml.j2
+++ b/salt/files/libvirt/domains/common.xml.j2
@@ -66,14 +66,30 @@
{%- endfor %}
+ {%- set vm_name_short = vm_name.split('.')[0] %}
+ {%- set vm_name_last_character = vm_name_short[-1] %}
+ {%- if vm_name_last_character.isdigit() %}
+ {%- set vm_cluster_index = vm_name_last_character %}
+ {%- else %}
+ {%- set vm_cluster_index = None %}
+ {%- endif %}
+ {%- set vm_interface_name = vm_name_short[:8] %}
+ {%- if not vm_interface_name.endswith(vm_name_last_character) and vm_cluster_index is not none %} {#- if name isn't short enough to already implicitly use its trailing number #}
+ {%- if '-' in vm_name_short %} {#- avoid confusion between, for example, "gitlab" and a truncated "gitlab-runner" #}
+ {%- set vm_name_short_split = vm_name_short.split('-') %}
+ {%- set vm_interface_name = vm_name_short_split[0][:6] ~ '-' ~ vm_name_short_split[1][:1] ~ vm_cluster_index %}
+ {%- else %}
+ {%- set vm_interface_name = vm_name_short[:8] ~ vm_cluster_index %}
+ {%- endif %}
+ {%- endif %}
{%- for interface, ifconfig in vm_interfaces.items() %}
{%- set iftype = ifconfig['type'] %}
-
+
-
+
{%- endfor %}