ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
343 stars 336 forks source link

vmware_guest creates VM on wrong esxi #216

Closed Akasurde closed 3 years ago

Akasurde commented 4 years ago

From @IvanBayan on Jun 02, 2020 11:17

SUMMARY

vmware_guest ignores esxi_hostname and places VM on other esxis in cluster.

ISSUE TYPE
COMPONENT NAME

vmware_guest

ANSIBLE VERSION
ansible 2.7.7
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]

ansible 2.9.9
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/tmp/ansible/lib/python3.7/site-packages/ansible
  executable location = /var/tmp/ansible/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]

ansible 2.10.0.dev0
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /tmp/ansible_devel/lib/python3.7/site-packages/ansible
  executable location = /tmp/ansible_devel/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
CONFIGURATION
ANSIBLE_PIPELINING(/home/user/.ansible.cfg) = True
HOST_KEY_CHECKING(/home/user/.ansible.cfg) = False
OS / ENVIRONMENT

vSphere Client version 6.7.0.40000

STEPS TO REPRODUCE

Inventory entry:

  children:
    ATL:
      hosts:
        fvsvacs002d.atl.example.com:
          Comments: tomcat
          Disk: 100
          Host Role: vcs/vas
          Hostname: fvsvacs002d.atl.example.com
          Ram: 8
          cobbler_profile: example-none-centos6-x86_65
          dc: ATL
          ds: atl_fgv002_fcdatastore003
          esxi: esxi321.atl.example.com
          folder: /FVS
          group: fgv
          ip_private: 10.8.104.65
          vcpu: 16
          vlan: 104

Task:

- name: Create a virtual machine on given ESXi hostname
  vmware_guest:
    hostname: "{{ vcenter_address }}"
    username: "{{ domain_user }}"
    password: "{{ domain_pass }}"
    datacenter: "{{ dc }}"
    validate_certs: no
    folder: "{{ folder }}"
    name: "{{ inventory_hostname }}"
    state: present
    guest_id: centos6_64Guest
    esxi_hostname: "{{ esxi }}"
    disk:
    - size_gb: "{{ Disk }}"
      type: thin
      autoselect_datastore: no
      datastore: "{{ ds }}"
    hardware:
      memory_mb: "{{ Ram * 1024}}"
      num_cpus: "{{ vcpu }}"
      num_cpu_cores_per_socket: "{{ vcpu }}"
      scsi: lsilogic
      version: 13
      boot_firmware: bios
    networks:
      - name: "VLAN{{ vlan }}"
        start_connected: True
        type: dhcp
    wait_for_ip_address: no
  delegate_to: localhost
  register: vm_deploy
EXPECTED RESULTS

VM should be created on esxi321.atl.example.com.

ACTUAL RESULTS
TASK [Create a virtual machine on given ESXi hostname] **************************************************************************************************************************************************************************************
task path: /home/user/example_local/git/utils/ansible/deploy_FGV/deploy.yml:31
Using module file /var/tmp/ansible/lib/python3.7/site-packages/ansible/modules/cloud/vmware/vmware_guest.py
Pipelining is enabled.
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: spirit
<localhost> EXEC /bin/sh -c '/var/tmp/ansible/bin/python3 && sleep 0'
changed: [fvsvacs002d.atl.example.com -> localhost] => {
    "changed": true,
    "instance": {
        "annotation": "",
        "current_snapshot": null,
        "customvalues": {},
        "guest_consolidation_needed": false,
        "guest_question": null,
        "guest_tools_status": "guestToolsNotRunning",
        "guest_tools_version": "0",
        "hw_cluster": "fgv002.atl",
        "hw_cores_per_socket": 16,
        "hw_datastores": [
            "atl_fgv002_fcdatastore003"
        ],
        "hw_esxi_host": "esxi223.atl.example.com",
        "hw_eth0": {
            "addresstype": "assigned",
            "ipaddresses": null,
            "label": "Network adapter 1",
            "macaddress": "00:50:56:b1:fa:86",
            "macaddress_dash": "00-50-56-b1-fa-86",
            "portgroup_key": null,
            "portgroup_portkey": null,
            "summary": "VLAN104"
        },
        "hw_files": [
            "[atl_fgv002_fcdatastore003] fvsvacs002d.atl.example.com/fvsvacs002d.atl.example.com.vmx",
            "[atl_fgv002_fcdatastore003] fvsvacs002d.atl.example.com/fvsvacs002d.atl.example.com.vmsd",
            "[atl_fgv002_fcdatastore003] fvsvacs002d.atl.example.com/fvsvacs002d.atl.example.com.vmdk"
        ],
        "hw_folder": "/ATL/vm/FVS",
        "hw_guest_full_name": null,
        "hw_guest_ha_state": null,
        "hw_guest_id": null,
        "hw_interfaces": [
            "eth0"
        ],
        "hw_is_template": false,
        "hw_memtotal_mb": 8192,
        "hw_name": "fvsvacs002d.atl.example.com",
        "hw_power_status": "poweredOff",
        "hw_processor_count": 16,
        "hw_product_uuid": "423158e2-7f14-65ba-66d4-a3c385fc7735",
        "hw_version": "vmx-13",
        "instance_uuid": "5031b213-695a-be22-a4d1-b6ddb54e23bd",
        "ipv4": null,
        "ipv6": null,
        "module_hw": true,
        "moid": "vm-4704",
        "snapshots": [],
        "vimref": "vim.VirtualMachine:vm-4704",
        "vnc": {}
    },
    "invocation": {
        "module_args": {
            "annotation": null,
            "cdrom": [],
            "cluster": null,
            "convert": null,
            "customization": {},
            "customization_spec": null,
            "customvalues": [],
            "datacenter": "ATL",
            "datastore": "atl_fgv002_fcdatastore003",
            "disk": [
                {
                    "size_gb": 100,
                    "type": "thin"
                }
            ],
            "esxi_hostname": "esxi321.atl.example.com",
            "folder": "/FVS",
            "force": false,
            "guest_id": "centos6_64Guest",
            "hardware": {
                "boot_firmware": "bios",
                "memory_mb": "8192",
                "num_cpu_cores_per_socket": 16,
                "num_cpus": 16,
                "scsi": "lsilogic",
                "version": 13
            },
            "hostname": "vcenter003.atl.example.com",
            "is_template": false,
            "linked_clone": false,
            "name": "fvsvacs002d.atl.example.com",
            "name_match": "first",
            "networks": [
                {
                    "name": "VLAN104",
                    "start_connected": true,
                    "type": "dhcp"
                }
            ],
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "resource_pool": null,
            "snapshot_src": null,
            "state": "present",
            "state_change_timeout": 0,
            "template": null,
            "use_instance_uuid": false,
            "username": "user",
            "uuid": null,
            "validate_certs": false,
            "vapp_properties": [],
            "wait_for_customization": false,
            "wait_for_ip_address": false
        }
    }
}

Copied from original issue: ansible/ansible#69831

ansibullbot commented 4 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 4 years ago

cc @Tomorrow9 @goneri @lparkes @nerzhul @pdellaert @pgbidkar @warthog9 click here for bot help

goneri commented 3 years ago

Closing since @xenlo PR https://github.com/ansible-collections/community.vmware/pull/400 fix the problem.

SpeedBlack commented 2 years ago

Hello all, I have the same problem with the "vmware_content_deploy_ovf_template" component. Do you know if this bug is fixed or will be fixed soon? I did not find exactly the information.

Thanks & regards