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

azure_rm_manageddisk_info managed_by not working #679

Closed
DII-dsward opened this issue Nov 9, 2021 · 10 comments
Closed

azure_rm_manageddisk_info managed_by not working #679

DII-dsward opened this issue Nov 9, 2021 · 10 comments
Labels
medium_priority Medium priority not a bug Not a bug work in In trying to solve, or in working with contributors

Comments

@DII-dsward
Copy link

Due to the dynamic inventory script not populating the names of the managed disks attached to a VM, I am trying to pull the names of the managed disks attached to a 'vm fqid'.

    - name: Get Disks managed by VM
      azure_rm_manageddisk_info:
        managed_by: "{{ id }}"
      register: vmdisks
    - debug:
        var: vmdisks

The error returned it...
fatal: [DVMANFSTEST01.dii.local]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (azure_rm_manageddisk_info) module: managed_by Supported parameters include: ad_user, adfs_authority_url, api_profile, append_tags, auth_source, cert_validation_mode, client_id, cloud_environment, name, password, profile, resource_group, secret, subscription_id, tags, tenant"}

Following this documentation
https://github.com/ansible-collections/azure/blob/dev/plugins/modules/azure_rm_manageddisk_info.py

SUMMARY

This playbook is returning an error saying managed_by is not a valid parameter

      azure_rm_manageddisk_info:
        managed_by: "{{ id }}"
ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure.azcollection.azure_rm_manageddisk_info

ANSIBLE VERSION

ansible 2.9

OS / ENVIRONMENT

Ansible Tower 3.8.4

@nbr23
Copy link
Contributor

nbr23 commented Nov 10, 2021

Hi @DII-dsward,
As far as I know, the best way to get this info today is to use azure_rm_virtualmachine_info and look at the returned data_disks list.

Edit: Disregard, this doesn't give as much info as I thought.

Cheers!

@kinect1things
Copy link

kinect1things commented Nov 11, 2021

I have checked azure_rm_virtualmachine_info, but it does not show the name of the disk. I'm not seeing how to use azure_rm_manageddisk to tag it if i cannot get the name of these disks.

---
- name: Get managed disks
  azure_rm_virtualmachine_info:
    resource_group: "{{ resource_group }}"
    name: "{{ inventory_hostname_short }}"
  register: vminfo
- debug:
    var: vminfo
"data_disks": [
                    {
                        "lun": 0,
                        "disk_size_gb": 10,
                        "managed_disk_type": "Standard_LRS",
                        "caching": "None"
                    }

@nbr23
Copy link
Contributor

nbr23 commented Nov 11, 2021

@kinect1things you're absolutely right, my bad!

However, jumping back to the original post, filtering azure_rm_manageddisk_info with managed_by does work if you give the full VM path (eg /subscriptions/XXXXXX-XXX-XXXX-XXX-XXXXXXXXXX/resourceGroups/RGNAME-eastus2/providers/Microsoft.Compute/virtualMachines/myVM).

This successfully lists the attached disks in my test cases:

    - name: Get Disks associated with my VM
      azure.azcollection.azure_rm_manageddisk_info:
        managed_by: /subscriptions/XXXXXX-XXX-XXXX-XXX-XXXXXXXXXX/resourceGroups/RGNAME-eastus2/providers/Microsoft.Compute/virtualMachines/myVM

@DII-dsward can you confirm which version of the azure collection you are using? I suspect you are using an older version. Support for this was merged in October 2020

@DII-dsward
Copy link
Author

This is the playbook i'm using

---
- hosts: vms
  connection: local
  collections:
    - azure.azcollection
  tasks:
     - debug:
        var: id
    - name: Get Disks managed by VM
      azure_rm_manageddisk_info:
        managed_by: "{{ id }}"
      register: vmdisks
    - debug:
        var: vmdisks

The Output looks like this

PLAY [vms] ***********************************************************
TASK [debug] *******************************************************************
ok: [SERVERNAME.domain.com] => {
    "id": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX/resourceGroups/resourcegroup1/providers/Microsoft.Compute/virtualMachines/SERVERNAME"
}
TASK [Get Disks managed by VM] *************************************************
fatal: [SERVERNAME.domain.com]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "msg": "Unsupported parameters for (azure_rm_manageddisk_info) module: managed_by Supported parameters include: ad_user, adfs_authority_url, api_profile, append_tags, auth_source, cert_validation_mode, client_id, cloud_environment, name, password, profile, resource_group, secret, subscription_id, tags, tenant"}
PLAY RECAP *********************************************************************
SERVERNAME.domain.com    : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

@nbr23
Copy link
Contributor

nbr23 commented Nov 11, 2021

@DII-dsward what does ansible-galaxy collection list azure.azcollection show on your system ?

@DII-dsward
Copy link
Author

Here is the output and ansible version.

$ ansible-galaxy collection list azure.azcollection
usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...
ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: 'list' (choose from 'init', 'build', 'publish', 'install')
$ ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/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)]

@nbr23
Copy link
Contributor

nbr23 commented Nov 12, 2021

@DII-dsward you're on an older version of ansible, so I think ansible-galaxy collection list doesn't work.

If you run ansible-galaxy collection install -vvv azure.azcollection, you will see the path where collections are installed as well as the version:

ansible-galaxy 2.9.27
  config file = None
  configured module search path = ['/home/nbr23/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /tmp/venv/lib/python3.9/site-packages/ansible
  executable location = /tmp/venv/bin/ansible-galaxy
  python version = 3.9.7 (default, Oct 10 2021, 15:13:22) [GCC 11.1.0]
No config file found; using defaults
Found installed collection azure.azcollection:1.10.0 at '/home/nbr23/.ansible/collections/ansible_collections/azure/azcollection'

Let me know what you get, but most likely your azcollection is outdated and you will need to install a newer version.

Thanks!

@Fred-sun
Copy link
Collaborator

@DII-dsward what does ansible-galaxy collection list azure.azcollection show on your system ?

@nbr23 According to your error log, you are using the old ansible-collections version, please upgrade the ansible-collection and try again. Thank you very much!

Upgrade to latest:   ansible-galaxy collection install azure.azcollection --force

@Fred-sun Fred-sun added medium_priority Medium priority not a bug Not a bug work in In trying to solve, or in working with contributors labels Nov 12, 2021
@nbr23
Copy link
Contributor

nbr23 commented Nov 12, 2021

@Fred-sun correct, I was reproducing the issue @DII-dsward is having. I agree this looks like they need to upgrade their collection :)

@DII-dsward
Copy link
Author

DII-dsward commented Nov 12, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority not a bug Not a bug work in In trying to solve, or in working with contributors
Projects
None yet
Development

No branches or pull requests

4 participants