community.vmware icon indicating copy to clipboard operation
community.vmware copied to clipboard

vmware_guest: MAC address conflict while doing the deployment from a template

Open Udayendu opened this issue 2 years ago • 12 comments

SUMMARY

vmware_guest is not able to handle the MAC distribution while doing the deployment of multiple vms from the same template. Its duplicating the MAC and as a result vms are not getting the IP as the nics are not getting attached.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • vmware_guest
ANSIBLE VERSION
$ pip3 show ansible
Name: ansible
Version: 5.8.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/local/lib/python3.8/dist-packages
Requires: ansible-core
Required-by:
COLLECTION VERSION
$ ansible-galaxy collection list community.vmware

# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.18.0
CONFIGURATION
  • No specific configurtaion
OS / ENVIRONMENT
  • vSphere 6.7 and 7.0
  • Ubuntu 20.04 LTS as provision server
  • Target OS: RHEL, OEL & Windows Server 2016
STEPS TO REPRODUCE
  • Use a play like below one:
- name: Gather info from WDC host
  vmware_guest_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: '{{ vsphere_datacenter }}'
    name: '{{ wdc_vm_name }}'
    validate_certs: 'no'
  delegate_to: localhost
  register: wdc_info

- name: Deploying vm from '{{ win_temp }}'
  vmware_guest:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: '{{ vsphere_datacenter }}'
    cluster: "{{ wdc_info['instance']['hw_cluster'] }}"
    datastore: "{{ wdc_info['instance']['hw_datastores'][0] }}"
    name: '{{ inventory_hostname }}'
    template: '{{ win_temp }}'
    folder: "{{ wdc_info['instance']['hw_folder'] }}"
    validate_certs: 'no'
    networks:
    - name: '{{ Mgmt_network }}'
      ip: "{{ Mgmt_network_ipv4 }}"
      netmask: '{{ Mgmt_network_nmv4 }}'
      gateway: '{{ Mgmt_network_gwv4 }}'
      dns_servers:
        - '{{ dns_server1 }}'
        - '{{ dns_server2 }}'
    state: poweredon
    wait_for_ip_address: yes
    customization:
      hostname: "{{ vsphere_vm_hostname }}"
      dns_suffix: '{{ ad_domain }}'
      domainadmin: '{{ ad_domain_admin }}'
      domainadminpassword: '{{ ad_domain_password }}'
      joindomain: '{{ ad_domain }}'
      timezone: '{{ timezone }}'
    wait_for_customization: yes
  delegate_to: localhost
EXPECTED RESULTS
  • vmware_guest should distribute the unique MAC to each vm
ACTUAL RESULTS
  • vmware_guest module is not able to assign the unique MAC. As a result the NICs are not getting attached and the IP configuration is not happening correctly.

Udayendu avatar Jul 12 '22 06:07 Udayendu

@goneri @Akasurde @Tomorrow9

Any thoughts around this ?

Udayendu avatar Jul 22 '22 05:07 Udayendu

Same problem here, when using customization against a Windows template :

  • deploying a Linux template without any customization works (new mac is given to the VM)
  • when deploying a Windows host from a template, with customization and network parameters, the VM gets the same MAC as the template, and the NIC is marked as "disconnected", even when specifying start_connected: true

Very annoying, we are unable to use Ansible to deploy Woindows template atm. Seems to be still the same as https://github.com/ansible/ansible/issues/64774 ? I will try the suggested patch.

xmontagut avatar Feb 01 '23 13:02 xmontagut

The patch from ansible issue 64774 works, the new VM now has a different MAC address, marked as "automatic" (not as manually attributed). I still have the issue about the NIC being disconnected at startup ; but about this problem, I can use vmware_guest_network afterwards.

xmontagut avatar Feb 01 '23 14:02 xmontagut

Hello, I am running into this problem today and am having trouble finding a workaround with the available modules. I am targeting vCenter / ESXi 6.7.0

I've tried using a customisation spec which is configured in vCenter to give a DHCP address, and then attempt to apply a static IP config afterwards, but this has also not worked.

With two VM's being created, one VM was given a new MAC address but then the NIC was left disconnected at power on. When connecting the NIC, the IP details specified in the config had not been applied.

The second VM retained the MAC address from the template it was cloned from. The NIC was showing as online, but no customisation was performed.

Does this affect newer vCenter versions - v7 or v8? The plan is to use v8 in production, but the available test rig is only at 6.7 for now.

edit: I am testing a possible workaround of limiting the vm-builder playbook to use serial: 1 to only attempt a single build at a time.

andyeff avatar Apr 25 '23 12:04 andyeff

Hello. This bug does not depend on the version of vСenter. The only workaround I found was to patch the module and use it instead of the original one.

Zawullon avatar Apr 25 '23 13:04 Zawullon

Thanks Zawullon, I will give that a try.

I've so far spun up 4 VM's in sequential fashion with the serial: 1 playbook parameter. Fortunately this is working for my requirement as I do not need to build a lot of VM's in one go and singular builds will be fine, but I will have a go with a patched module as a parallel deployment would be preferable if I can get it working.

andyeff avatar Apr 25 '23 13:04 andyeff

I was able to create four VM's in one batch, with NIC customisations successfully applied, after making the changes in the patch referenced in the old ansible repository.

I've created a pull request linked to this issue to see if this helps implement the fix into the community modules here.

andyeff avatar Apr 25 '23 14:04 andyeff

Thanks @andyeff for the patch. Will test and update you.

For windows template, when I am making the template I am not adding any nic. And in that case there is no issue if I am trying to map multiple nics using ansible.

pingtouskar avatar Apr 28 '23 16:04 pingtouskar

vSphere: 7.x ansible: 2.13.11 community.vmware: 3.9.0

We are also affected by this issue and and would love to see this pull-request merged, but the automated checks seem stuck instead of failed. Is there a way to get this rolling again?

Bytesalat avatar Nov 09 '23 13:11 Bytesalat

Also affected by this issue

Waiting for #1716 merge

t106362512 avatar Feb 13 '24 19:02 t106362512

Hi,

we are also affected by this issue. It would be nice if https://github.com/ansible-collections/community.vmware/pull/1716 could be merged.

chschenk avatar Feb 28 '24 09:02 chschenk