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: parameter like controller_type or unit_number should convert to int firstly #274

Closed
Tomorrow9 opened this issue Jul 3, 2020 · 0 comments · Fixed by #277
Closed
Assignees

Comments

@Tomorrow9
Copy link
Collaborator

Tomorrow9 commented Jul 3, 2020

SUMMARY

Parameters' values with "int" type should be converted to int firstly using "integer_value" function. Or it will pass string type of value when setting it to a variable.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest

ANSIBLE VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
- name: "Reconfigure VM CDROM"
  vmware_guest:
    hostname: "{{ vc }}"
    username: "{{ vc_user }}"
    password: "{{ vc_password }}"
    validate_certs: "{{ valid_cert }}"
    datacenter: "{{ vc_datacenter }}"
    folder: "{{ vm_folder }}"
    name: "{{ vm_name }}"
    cdrom:
      - type: "{{ cdrom_type }}"
        iso_path: "{{ cdrom_iso_file | default(omit) }}"
        controller_type: "{{ cdrom_controller | default(omit) }}"
        controller_number: "{{ cdrom_controller_num }}"
        unit_number: "{{ cdrom_unit_num }}"
        state: "present"
  register: vm_result
EXPECTED RESULTS

When int type parameter's value is set to other variable, and this variable's value is not set to an integer directly, then passed parameter's value is treated as string type. So in the code, we need to convert it to int firstly before validate it's value.

ACTUAL RESULTS
TASK [Reconfigure VM CDROM] **************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Invalid cdrom.controller_number: 0 or cdrom.unit_number: 1, valid values are 0 or 1 for IDE controller."}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant