Uploaded image for project: 'Ansible Cloud Automation'
  1. Ansible Cloud Automation
  2. ACA-1255

[vmware.vmware_rest/389] vmware.vmware_rest.vcenter_vm_guest_power returns `changed: false` when shutting down a VM

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      https://github.com/ansible-collections/vmware.vmware_rest/issues/389
      Ansible version:
      ```
      ansible [core 2.11.12]
      config file = /home/user/.ansible.cfg
      configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = /opt/ansible/os9_prov_vmw_20230117/lib64/python3.6/site-packages/ansible
      ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
      executable location = /opt/ansible/os9_prov_vmw_20230117/bin/ansible
      python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
      jinja version = 3.0.3
      libyaml = True
      ```
      Collection version:
      ```
      vmware.vmware_rest 2.2.0
      ```
      The implementation:
      ```yaml

      • name: "The VM is powered off"
        delegate_to: localhost
        vmware.vmware_rest.vcenter_vm_guest_power:
        vcenter_hostname: "{{ svrreq_vm.vcenter }}"
        vcenter_username: "{{ survey_username }}"
        vcenter_password: "{{ survey_password }}"
        vm: "{{ deployed_vm.vm_deploy_info.vm_id }}"
        state: shutdown
        register: vm_shutdown
        ```
        The result when the VM was running before the call:
        ```
        ok: [localhost -> localhost] => {
        "changed": false,
        "invocation":
        Unknown macro: { "module_args"}

        ,
        "value": {}
        }
        ```
        The result when the VM was powered off before the call:
        ```
        ok: [localhost -> localhost] => {
        "changed": false,
        "invocation":

        Unknown macro: { "module_args"}

        ,
        "value":

        Unknown macro: { "error_type"}

        }
        ```

        1. Expected results:
          `changed: true` is returned by the module when there is a power state change.
        1. Actual results:
          `changed: false` is returned by the module when there is a power state change. To actually detect a power state change I would need to call `vmware.vmware_rest.vcenter_vm_guest_power_info` first and compare the power state to the result of this call to detect a change. This would get messy when changing the power state of more than one VM at a time.

            Unassigned Unassigned
            mgraves1@redhat.com Mike Graves
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: