vmware_guest module does not assign custom MAC address if building a VM from a template
acozine opened this issue · 0 comments
acozine commented
SUMMARY
Possibly related to #1391 and/or #1158.
When building a new VM with the vmware_guest
module using a template, the MAC address is automatically assigned even if you pass a custom MAC address.
I reported this in this forum post, and other users confirmed the bug.
ISSUE TYPE
- Bug Report
COMPONENT NAME
vmware_guest
module
ANSIBLE VERSION
% ansible --version
ansible [core 2.16.3]
python version = 3.11.1 (main, Jun 23 2023, 15:42:22)
COLLECTION VERSION
community.vmware 4.0.1
OS / ENVIRONMENT
vCenter 7.0.3
ESXi 7.0.3
STEPS TO REPRODUCE
Run a playbook with a single task that builds a new VM and passes a custom MAC address.
Replace the values in this example task with ones that match your environment.
- name: Create a VM with specific MAC address
community.vmware.vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
datacenter: "{{ vcenter_datacenter }}"
cluster: "{{ vcenter_cluster }}"
folder: /{{ vm_folder | default('dev-vms') }}
name: test-custom-mac-address
state: present
template: "{{ vm_template | default('template_2024')}}"
disk:
- size_gb: 30
type: thin
datastore: "{{ vm_info.datastore_url }}"
hardware:
memory_mb: "{{ vm_memory | default('8192') }}"
num_cpus: "{{ vm_cpus | default('2') }}"
num_cpu_cores_per_socket: "{{ vm_cpu_cores | default('1') }}"
scsi: paravirtual
version: latest
boot_firmware: "efi"
cdrom:
- controller_number: 0
unit_number: 0
state: present
networks:
- name: "{{ vm_network | default('VM Network')}}"
mac: "00:11:22:aa:bb:cc" # put a valid mac address here
EXPECTED RESULTS
Task creates a new VM with the custom MAC address.
ACTUAL RESULTS
Task created a new VM with an automatically-supplied MAC address.
WORKAROUNDS
- If you create the VM from scratch, you can pass a custom MAC address and it works.
- If you create the VM from the template, you can add a second NIC with the custom MAC address, power the VM down, remove the NIC with the automatically-supplied MAC address, and power the VM back up again. Once that's done, your
eth0
will have the correct MAC address.