Skip to content

community.vmware.vmware_guest cannot add a cd-rom with an iso file loaded if the vmware already exists #1028

Open
@AaronJaegerVA

Description

@AaronJaegerVA
SUMMARY

community.vmware.vmware_guest cannot add a cd-rom with an iso file loaded if the vm already exists

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.vmware.vmware_guest

ANSIBLE VERSION
ansible 2.9.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/vhaispjaegea0/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
COLLECTION VERSION
ansible-galaxy collection list community.vmware
usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...
ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: u'list' (choose from 'init', 'build', 'publish', 'install')
CONFIGURATION
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 20
OS / ENVIRONMENT

RHEL8 on ESXi 6.7 Update 3

STEPS TO REPRODUCE
  1. Create a new guest without a cd-rom or with a cd-rom with type: client
  2. Run the vmware_guest module again against the same guest, but this time, set the cd-rom to type: iso and set an iso_path
- name: Deploy a VM without a CD-ROM
  vmware_guest:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datacenter: "{{ vcenter_dc }}"
    cluster: "{{ vcenter_cluster }}"
    datastore: "{{ guest_datastore }}"
    folder: "{{ guest_folder }}"
    name: "{{ guest_name }}"
    guest_id: "{{ guest_id | default('rhel8_64Guest') }}" 
    annotation: "{{ guest_note }}"
    template: "{{ guest_template_name | default(omit) }}"
    hardware:
      boot_firmware: efi
      secure_boot: yes
      version: 15
      num_cpus: "{{ vm_num_cpus | default('4') }}"
      num_cpu_cores_per_socket: "{{ vm_num_cpu_cores_per_socket | default('2') }}"
      memory_mb: "{{ vm_memory_mb | default('16384') }}"
    networks:
      - connected: yes
        start_connected: yes
        device_type: vmxnet3
        name: "{{ vm_network_name | default('NewLab -177') }}"
    state: "{{ vm_state | default('poweredoff') }}"
  delegate_to: "{{ env_control_host }}"
  register: deploy_no_cdrom_result
  when: cdrom_type is not defined

- name: Deploy a VM with a CD-ROM
  vmware_guest:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datacenter: "{{ vcenter_dc }}"
    cluster: "{{ vcenter_cluster }}"
    datastore: "{{ guest_datastore }}"
    folder: "{{ guest_folder }}"
    name: "{{ guest_name }}"
    guest_id: "{{ guest_id | default('rhel8_64Guest') }}" 
    annotation: "{{ guest_note }}"
    template: "{{ guest_template_name | default(omit) }}"
    hardware:
      boot_firmware: efi
      secure_boot: yes
      version: 15
      num_cpus: "{{ vm_num_cpus | default('4') }}"
      num_cpu_cores_per_socket: "{{ vm_num_cpu_cores_per_socket | default('2') }}"
      memory_mb: "{{ vm_memory_mb | default('16384') }}"
    networks:
      - connected: yes
        start_connected: yes
        device_type: vmxnet3
        name: "{{ vm_network_name | default('NewLab -177') }}"
        mac: "{{ new_vm_mac_address | default(omit) }}"
    cdrom:
      - type: "{{ cdrom_type }}"
        iso_path: "{{ cdrom_iso_path }}"
        controller_type: "{{ cdrom_controller_type }}"
        controller_number: "{{ cdrom_controller_number }}"
        unit_number: "{{ cdrom_unit_number }}"
        state: "{{ cdrom_state }}"
    state: "{{ vm_state | default('poweredoff') }}"
  delegate_to: "{{ env_control_host }}"
  register: deploy_with_cdrom_result
  when: cdrom_type is defined
EXPECTED RESULTS

I expect the cd-rom to be added and the ISO file loaded.

ACTUAL RESULTS

The cd-rom is created as a Client device despite type: iso and iso_path: ...

{
    "instance": {
        "hw_name": "vhaispbckcvfrel1",
        "hw_power_status": "poweredOn",
        "snapshots": [],
        "guest_question": null,
        "hw_interfaces": [
            "eth0"
        ],
        "hw_guest_id": null,
        "current_snapshot": null,
        "hw_eth0": {
            "macaddress": "00:50:56:ac:57:0d",
            "addresstype": "assigned",
            "macaddress_dash": "00-50-56-ac-57-0d",
            "summary": "DVSwitch: 95 9f 2c 50 27 6a 7f e8-c5 ac 13 10 26 c4 4a 0a",
            "portgroup_portkey": "902",
            "ipaddresses": null,
            "portgroup_key": "dvportgroup-1946156",
            "label": "Network adapter 1"
        },
        "hw_folder": "/ESE/ETS/BAY-ETS/vm",
        "customvalues": {},
        "hw_files": [
            "[SAN3PAR07] vhaispbckcvfrel1_1/vhaispbckcvfrel1.vmx",
            "[SAN3PAR07] vhaispbckcvfrel1_1/vhaispbckcvfrel1.vmsd",
            "[SAN3PAR07] vhaispbckcvfrel1_1/vhaispbckcvfrel1.nvram"
        ],
        "ipv4": null,
        "ipv6": null,
        "hw_product_uuid": "422c162b-5082-01fe-cdec-e7e63cc4f362",
        "hw_is_template": false,
        "vnc": {},
        "module_hw": true,
        "hw_guest_ha_state": false,
        "guest_consolidation_needed": false,
        "hw_guest_full_name": null,
        "guest_tools_status": "guestToolsNotRunning",
        "guest_tools_version": "0",
        "annotation": "VM deployed by Ansible",
        "instance_uuid": "502ca878-ab14-7ea2-d707-e1d113308a74",
        "hw_version": "vmx-15",
        "hw_processor_count": 4,
        "hw_memtotal_mb": 16384,
        "hw_datastores": [
            "SAN3PAR07"
        ],
        "moid": "vm-8236336",
        "hw_esxi_host": "vhaispvshesxi31.vha.med.va.gov",
        "hw_cores_per_socket": 2,
        "hw_cluster": "VHAISPNEWLAB",
        "vimref": "vim.VirtualMachine:vm-8236336"
    },
    "_ansible_no_log": false,
    "_ansible_delegated_vars": {
        "ansible_port": null,
        "ansible_host": "vhaispopsans001.vha.med.va.gov",
        "ansible_user": "..."
    },
    "invocation": {
        "module_args": {
            "resource_pool": null,
            "force": false,
            "customization_spec": null,
            "hardware": {
                "memory_mb": "16384",
                "version": 15,
                "secure_boot": true,
                "boot_firmware": "efi",
                "num_cpus": "4",
                "num_cpu_cores_per_socket": "2"
            },
            "cluster": "VHAISPNEWLAB",
            "wait_for_customization": false,
            "customization": {},
            "datastore": "SAN3PAR07",
            "disk": [],
            "port": 443,
            "wait_for_ip_address": false,
            "uuid": null,
            "customvalues": [],
            "hostname": "vaorlappvc01.vha.med.va.gov",
            "is_template": false,
            "networks": [
                {
                    "start_connected": true,
                    "connected": true,
                    "name": "NewLab -177",
                    "device_type": "vmxnet3"
                }
            ],
            "state": "poweredon",
            "template": null,
            "linked_clone": false,
            "folder": "/ESE/ETS/BAY-ETS/vm/",
            "username": "...",
            "snapshot_src": null,
            "convert": null,
            "proxy_port": null,
            "name_match": "first",
            "cdrom": [
                {
                    "controller_type": "ide",
                    "controller_number": "0",
                    "state": "present",
                    "type": "iso",
                    "unit_number": "0",
                    "iso_path": "[SAN3PAR07] ISO/Kickstart/vhaispbckcvfrel1.vha.med.va.gov_20210908_0702.iso"
                }
            ],
            "use_instance_uuid": false,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "annotation": "VM deployed by Ansible",
            "datacenter": "BAY-ETS",
            "state_change_timeout": 0,
            "name": "vhaispbckcvfrel1",
            "guest_id": "rhel8_64Guest",
            "proxy_host": null,
            "vapp_properties": [],
            "esxi_hostname": null,
            "validate_certs": true
        }
    },
    "changed": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugneeds_triageNeeds a first human triage before being processed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions