azure icon indicating copy to clipboard operation
azure copied to clipboard

azure_rm_virtualmachine_info does not return VMs using a managed storage account for boot diagnostics

Open clsmith70 opened this issue 4 years ago • 1 comments

This is related to issue #137.

SUMMARY

When I run a play to get all VMs in Azure of a specific VM by name, it always returns "Error getting virtual machine None - 'storageUri'" for the all VMs list and "Error getting virtual machine MyVM - 'storageUri'" for the specific VM

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_virtualmachine_info

ANSIBLE VERSION
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Aug 12 2021, 07:06:15) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
COLLECTION VERSION
Command not available in Ansible 2.9
Installed the latest available for this release (Red Hat subscription)
CONFIGURATION
NULL
STEPS TO REPRODUCE
---
- hosts: localhost
  gather_facts: yes

  tasks:
  - name: List all VMs in {{ resource_group }}
    azure_rm_virtualmachine_info:
      resource_group: "{{ resource_group }}"
EXPECTED RESULTS

The expected out put for the list all vms task should be

TASK [List all VMs in rg_ansible_preprod_eastus2] **************************************************************** ok: [localhost]

ACTUAL RESULTS
PLAY [localhost] *************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************
ok: [localhost]

TASK [List all VMs in rg_ansible_preprod_eastus2] ****************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error getting virtual machine None - 'storageUri'"}

PLAY RECAP *******************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

When a VM boot diagnostics configuration is set to "Enable with managed storage account (recommended)" the play fails with the error listed.  The same happens for a similar play that also includes a VM name to limit the returned data.  If the boot diagnostics storage account is user configured, it works fine.  In my personal test tenant I can change this value to "work around" the issue, but at work where most VMs use the recommended setting, this is not the case.

clsmith70 avatar Oct 17 '21 20:10 clsmith70

@clsmith70 Thank you for submitting this question, but I have confirmed the question you submitted, and the conclusion is as follows: only the return of disable boot diagnostics is empty, and no error will be reported! Thank you very much!

In disable boot diagnostics state, the return value is as follows:
"boot_diagnostics": {
                    "enabled": false,
                    "storage_uri": false
                }
In enable boot diagnostics state, the return value is as follows:
                "boot_diagnostics": {
                    "console_screenshot_uri": null,
                    "enabled": true,
                    "serial_console_log_uri": null,
                    "storage_uri": null
                }
In enable boot diagnostics state(Enable with custom storage account
), the return value is as follows:
                "boot_diagnostics": {
                    "console_screenshot_uri": "https://vxisurg02diag.blob.core.windows.net/*****64b5.screenshot.bmp",
                    "enabled": true,
                    "serial_console_log_uri": "https://vxisurg02diag.blob.core.windows.net/***566864b5.serialconsole.log",
                    "storage_uri": "https://vxisurg02diag.blob.core.windows.net/"
                }

Fred-sun avatar Oct 19 '21 02:10 Fred-sun