ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
244 stars 325 forks source link

Dynamic inventory plugin fails with status code 500 #839

Closed theasianpianist closed 6 months ago

theasianpianist commented 2 years ago
SUMMARY

Trying to use the dynamic inventory plugin fails with the following error:

[WARNING]:  * Failed to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml with auto plugin: a batched request failed with status code 500, url /subscriptions/e28b7061-2d6e-4d88-acd3-e
ab88c4189c5/resourceGroups/vmss_sonic_gemini_workers_westus2/providers/Microsoft.Compute/virtualMachineScaleSets/vmss_sonic_gemini_workers_pool8/virtualMachines
[WARNING]:  * Failed to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is
reserved to provide a port.
[WARNING]: Unable to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:
ISSUE TYPE
COMPONENT NAME

azure.azcollection.azure_rm

ANSIBLE VERSION
ansible [core 2.12.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/lawlee/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/lawlee/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True
COLLECTION VERSION
# /home/lawlee/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.12.0

# /usr/lib/python3/dist-packages/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.12.0
CONFIGURATION
No changes
OS / ENVIRONMENT

Host device:

❯ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
❯ uname -a
Linux lawlee-dev-vm0 5.11.0-1022-azure #23~20.04.1-Ubuntu SMP Fri Nov 19 10:20:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Target VMs in Azure belong to a VMSS running Ubuntu Server 20.04 LTS

STEPS TO REPRODUCE
ansible-inventory -i inv_azure_rm.yaml --graph

Contents of inv_azure_rm.yaml:

#
#

plugin: azure.azcollection.azure_rm

include_vmss_resource_groups:
- <vmss resource group name>

conditional_groups:
  pdisk: "'pool8' in name"

auth_source: auto
EXPECTED RESULTS

I expect the inventory graph to be printed succesfully

ACTUAL RESULTS
[WARNING]:  * Failed to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml with auto plugin: a batched request failed with status code 500, url /subscriptions/e28b7061-2d6e-4d88-acd3-e
ab88c4189c5/resourceGroups/vmss_sonic_gemini_workers_westus2/providers/Microsoft.Compute/virtualMachineScaleSets/vmss_sonic_gemini_workers_pool8/virtualMachines
[WARNING]:  * Failed to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is
reserved to provide a port.
[WARNING]: Unable to parse /home/lawlee/sonic-jenkins/gemini_azure_rm.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:
Fred-sun commented 2 years ago

@theasianpianist Thank you very much for reporting this problem. First of all, I tested locally and could obtain inventory information. You returned nothing. Can you confirm that the resource group you want to obtain has a VM? Is the current network accessible through SSH? Thank you very much!

theasianpianist commented 2 years ago

@Fred-sun I can confirm that the resource group in question contains VMs (as well as VMSS instances), and I am able to SSH to all VMs from the same machine I'm running Ansible on. I did observe some interesting behavior - the above bug only occurs if I attach data disks to the Virtual Machine Scale Set listed under include_vmss_resource_groups in the inventory file. If I remove all data disks from the VMSS and then update all VM instances, then the dynamic inventory is able to be loaded properly.

Fred-sun commented 2 years ago

@theasianpianist Got it. I'll look into it. Thank you very much!

Fred-sun commented 1 year ago

@theasianpianist Could you please help to confirm whether there is any error in the resource group where your VMSS resides? The only way I can repeat the error is - the name of the resource group where VMSS resides is incorrect!


include_vmss_resource_groups:
- <The VMSS's resource group is not exist>
theasianpianist commented 1 year ago

@Fred-sun from what I remember, the resource group was spelled correctly since I was able to get it working when I removed the data disks, it only produced the failure when I tried this operation with data disks attached to the VMSS.

Fred-sun commented 1 year ago

@theasianpianist I'm not sure what you mean, whether you are adding the data disk to the VMSS or to the VM instance. I still can't repeat your question, thank you!


Please update your ansible-collections to lastest(v1.14.0).
      ansible-galaxy collection install azure.azcollection --force
pranav-desai-bluejeans commented 1 year ago

hi @Fred-sun I'm also facing this issue, not sure what resolution needs to be applied for this, can you please let me know on the same?

Fred-sun commented 1 year ago

@theasianpianist @pranav-desai-bluejeans I'm sorry for replying you so late, because I have been unable to repeat this problem, and there is no way to provide the next step solution now! Thanks!

Fred-sun commented 1 year ago

@theasianpianist In addition, The file name in your report issue is 'gemini_azure_rm.yaml', But you are executing 'ansible-inventori-i inv_azure_rm.yaml --graph' Is the problem you are reporting inconsistent with your playbook?

Fred-sun commented 7 months ago

@theasianpianist Does your problem still exist? After repeated deliberation, I still can't figure out what this mistake is? Can you update to the latest version and try again? Thank you very much!

theasianpianist commented 6 months ago

@Fred-sun unfortunately the infrastructure that I saw this problem on is no longer available, and I have no way to try to reproduce the problem anymore :( feel free to close this unless @pranav-desai-bluejeans is able to share reproduction steps?

Fred-sun commented 6 months ago

@theasianpianist @pranav-desai-bluejeans Ok, I will close this question for the moment, if you have new questions, you are welcome to continue to submit. Thank you!