Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions roles/libvirt_manager/tasks/generate_macs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
vm: "{{ _vm.key }}"
_vm_type: "{{ _vm.value }}"
_mac_seed: "{{ '52:54:%02i' % vm_id }}"
_fixed_mac: "{{ _mac_seed | community.general.random_mac }}"
# We don't generate MAC for spineleafnets - if that one is set
# we won't get "nets" entry. Just use an empty list in that case.
_nets_list: >-
Expand All @@ -25,14 +24,15 @@
{% set _macs = cifmw_libvirt_manager_mac_map[vm] -%}
{% endif -%}
{% for network in _nets_list -%}
{% set _net_mac = ('52:54:%02i:%02i' % (vm_id, loop.index0)) | community.general.random_mac -%}
{% if cifmw_libvirt_manager_mac_map |
dict2items | selectattr('key', 'equalto', vm) |
map(attribute='value') | first | default([]) |
items2dict(key_name='network', value_name='mac') |
dict2items | map(attribute='key') |
select('equalto', network) | length == 0 -%}
{% set _ = _macs.append({'network': network,
'mac': _fixed_mac }) -%}
'mac': _net_mac }) -%}
{% endif -%}
{% endfor -%}
{% if _macs | length != 0 -%}
Expand Down
Loading