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

disk.controller_number and disk.unit_number set to 0 results in validation error because 0 == false in v1.8 #703

Closed
MalfuncEddie opened this issue Mar 9, 2021 · 6 comments · Fixed by #705
Labels
bug This issue/PR relates to a bug cloud has_pr module module needs_triage Needs a first human triage before being processed. plugins plugin (any type) python3

Comments

@MalfuncEddie
Copy link

MalfuncEddie commented Mar 9, 2021

SUMMARY

Since v1.8 My playbook stopped working with the error

disk.controller_type', 'disk.controller_number' and 'disk.unit_number' are mandatory parameters when configure multiple disk controllers and disks.

Checking my playbook it does have all the parameters

reverting to version 1.7 did fix the issue. I think this might be due to #640 but can"t pinpoint the issue

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.vmware/plugins/modules/vmware_guest.py

ANSIBLE VERSION
ansible 2.10.3
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /data/awx/awx_venvs/vmware_community/lib64/python3.6/site-packages/ansible
  executable location = /data/awx/awx_venvs/vmware_community/bin/ansible
  python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

CONFIGURATION

empty


OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
- name: Alter VM template
  community.vmware.vmware_guest:
    validate_certs: False
    hostname: '{{ lookup("env", "VMWARE_HOST") }}'
    username: '{{ lookup("env", "VMWARE_USER") }}'
    password: '{{ lookup("env", "VMWARE_PASSWORD") }}'
    host: "{{ set_esxi_hostname | default(omit) }}"
    cluster: "{{ set_cluster | default(omit) }}"
    datacenter: "{{ datacenter }}"
    folder: "{{ folder }}"
    name: "{{ vmname }}"
    customization:
      existing_vm: True
      hostname: "{{ vm_hostname | default(omit)}}"
    disk:
    - size_gb: "{{ disk_size }}"
      type: "{{ disktype |lower }}"
      controller_type : 'paravirtual'
      datastore: "{{ datastore_recommended }}"
      controller_number: 0
      unit_number: 0
    hardware:
      hotadd_memory: True
      memory_mb: "{{ vm_memory  }}"
      num_cpus: "{{ cpu  }}"
      boot_firmware: "{{ boot_firmware  }}"
      scsi: "{{ scsi }}"
    networks:
    - name: "{{ port_grp }}"
      device_type: "vmxnet3"
      start_connected: True
      type: "{{ net_type }}"
      ip: "{{ server_ip }}"
      netmask: "{{ netmask }}"
      gateway: "{{ gateway }}"
      domain: "{{ searchdomain }}"
      dns_servers:
        - "{{ dns1 }}"
        - "{{ dns2 }}"
    state: present

output (some info censored)

"msg": "'disk.controller_type', 'disk.controller_number' and 'disk.unit_number' are mandatory parameters when configure multiple disk controllers and disks.",
    "invocation": {
        "module_args": {
            "validate_certs": false,
            "hostname": "censored",
            "username": "censored",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "cluster": "censored",
            "datacenter": "censored",
            "folder": "vm",
            "name": "censored",
            "customization": {
                "existing_vm": true,
                "autologon": null,
                "autologoncount": null,
                "dns_servers": null,
                "dns_suffix": null,
                "domain": null,
                "domainadmin": null,
                "domainadminpassword": null,
                "fullname": null,
                "hostname": null,
                "hwclockUTC": null,
                "joindomain": null,
                "joinworkgroup": null,
                "orgname": null,
                "password": null,
                "productid": null,
                "runonce": null,
                "timezone": null
            },
            "disk": [
                {
                    "size_gb": 45,
                    "type": "eagerzeroedthick",
                    "controller_type": "paravirtual",
                    "datastore": "censored",
                    "controller_number": 0,
                    "unit_number": 0,
                    "autoselect_datastore": null,
                    "disk_mode": null,
                    "filename": null,
                    "size": null,
                    "size_kb": null,
                    "size_mb": null,
                    "size_tb": null
                }
            ],
            "hardware": {
                "hotadd_memory": true,
                "memory_mb": 8096,
                "num_cpus": 2,
                "boot_firmware": "efi",
                "scsi": "paravirtual",
                "cpu_limit": null,
                "cpu_reservation": null,
                "hotadd_cpu": null,
                "hotremove_cpu": null,
                "max_connections": null,
                "mem_limit": null,
                "mem_reservation": null,
                "memory_reservation_lock": null,
                "nested_virt": null,
                "num_cpu_cores_per_socket": null,
                "version": null,
                "virt_based_security": null
            },
            "networks": [
                {
                    "name": "censored",
                    "device_type": "vmxnet3",
                    "start_connected": true,
                    "type": "static",
                    "ip": "censored",
                    "netmask": "censored",
                    "gateway": "censored",
                    "domain": "censored",
                    "dns_servers": [
                        "censored",
                        "censored"
                    ]
                }
            ],
            "state": "present",
            "port": 443,
            "is_template": false,
            "customvalues": [],
            "advanced_settings": [],
            "name_match": "first",
            "use_instance_uuid": false,
            "cdrom": [],
            "force": false,
            "wait_for_ip_address": false,
            "wait_for_ip_address_timeout": 300,
            "state_change_timeout": 0,
            "linked_clone": false,
            "wait_for_customization": false,
            "wait_for_customization_timeout": 3600,
            "vapp_properties": [],
            "delete_from_inventory": false,
            "proxy_host": null,
            "proxy_port": null,
            "template": null,
            "annotation": null,
            "uuid": null,
            "guest_id": null,
            "esxi_hostname": null,
            "snapshot_src": null,
            "resource_pool": null,
            "customization_spec": null,
            "datastore": null,
            "convert": null
        }
    },
    "_ansible_no_log": false,
    "changed": false

ACTUAL RESULTS

@ansibullbot
Copy link

Files identified in the description:
None

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 ansibullbot added bug This issue/PR relates to a bug needs_triage Needs a first human triage before being processed. python3 labels Mar 9, 2021
@ansibullbot
Copy link

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
Copy link

@ansibullbot ansibullbot added cloud module module plugins plugin (any type) labels Mar 9, 2021
@MalfuncEddie
Copy link
Author

Hi

if not disk_spec['controller_type'] or not disk_spec['controller_number'] or not disk_spec['unit_number']:

should be changed to

 if not disk_spec['controller_type'] or (not disk_spec['controller_number'] and disk_spec['controller_number'] != 0) or (not disk_spec['unit_number'] and disk_spec['controller_number'] != 0):
            

Because it errors if the number is 0

@MalfuncEddie MalfuncEddie changed the title Disk spec detection does not detect mandatory field in v1.8 disk.controller_number and disk.unit_number set to 0 results in validation error because 0 == false in v1.8 Mar 9, 2021
@mariolenz
Copy link
Collaborator

@MalfuncEddie You're right, the problem is that not 0 is True. So I think the best way is to fail if 'disk.controller_type', 'disk.controller_number' or 'disk.unit_number' is None.

Can you please have a look at PR #705? I hope it will fix this.

@MalfuncEddie
Copy link
Author

@mariolenz #705 looks good to me,
Just tested it and no issue. Tnx for the great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug cloud has_pr module module needs_triage Needs a first human triage before being processed. plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants