Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_guest without MAC address gather facts error #28471

Closed
tmarlok88 opened this issue Aug 21, 2017 · 4 comments
Closed

vmware_guest without MAC address gather facts error #28471

tmarlok88 opened this issue Aug 21, 2017 · 4 comments
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community

Comments

@tmarlok88
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest

ANSIBLE VERSION
ansible 2.3.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

OS / ENVIRONMENT

"N/A"

SUMMARY

If the guest vm has no MAC address assigned to it (prior the first boot, th e MAC is empty), the guest module is unable to start the vm. The problem lies in the module_utils/vmware.py in the gather_vm_facts function (line 247). The error is:

AttributeError: 'NoneType' object has no attribute 'replace'

I made the following workaround to make it work:

        macaddress_dash = ''
        if entry.macAddress:
            macaddress_dash = entry.macAddress.replace(':', '-' )

        factname = 'hw_eth' + str(ethernet_idx)
        facts[factname] = {
            'addresstype': entry.addressType,
            'label': entry.deviceInfo.label,
            'macaddress': entry.macAddress,
            'ipaddresses': net_dict.get(entry.macAddress, None),
            'macaddress_dash': macaddress_dash,
            'summary': entry.deviceInfo.summary,
        }
STEPS TO REPRODUCE

First the assigned MAC address should be removed from the VM. Then one can try to start the vm with the folloving task:

- name: start the guest vm
  vmware_guest:
    hostname: "{{ansible_hos] }}"
    username: "{{esxi_admin_user}}"
    password: "{{esxi_admin_password}}"
    validate_certs: no
    name: "{{ inventory_hostname }}"
    wait_for_ip_address: yes
    state: poweredon
@ansibot
Copy link
Contributor

ansibot commented Aug 21, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Aug 21, 2017
@Akasurde
Copy link
Member

@tmarlok88 Are you interested in raising PR against 2.3 branch ?

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Aug 21, 2017
@tmarlok88
Copy link
Contributor Author

I just checked out the devel branch and it looks like this issue is already fixed there

Akasurde added a commit to Akasurde/ansible that referenced this issue Aug 22, 2017
When vm has no MAC address assigned to it. Fix handles
attribute error if MAC address is not set.

Fixes: ansible#28471

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde
Copy link
Member

resolved_by_pr #28500

dagwieers pushed a commit that referenced this issue Aug 31, 2017
When vm has no MAC address assigned to it. Fix handles
attribute error if MAC address is not set.

Fixes: #28471

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

No branches or pull requests

3 participants