How to know nested_attributes names for ovirt_* modules in ansible? How to fetch them all?

331 Views Asked by At

To my surprise, since ansible 2.9 (I believe) ovirt info modules nested dictrionaries are not fetched by default. And, as most valuable data usually resides there, I'm looking for easy way to get them. Just setting

fetch_nested: yes

gives usually only ids, which is not of very userful, to get desired data I need to know the exact name of attribute's dictionary for given module, which is problematic untill I see the output with that dictironary fetched (chicken or the egg).

The docs are very stingy in regards of attibute names, for example:

- nested_attributes Specifies list of the attributes which should be fetched from the API. This parameter apply only when fetch_nested' is true'. [Default: (null)] type: list version_added: 2.3

This entry is the same in docs for most ovirt*_info modules, e.g. ovirt_event_info, ovirt_storage_domain_info, ovirt_nic_info (which have different nested data and different attribute names).

It would be very nice if there were a way to fetch them all, something like:

        nested_attributes: 
        - all

Sadly this doesn't work. I would appreciate if someone point me to obvious way to get attr names, without it I find ovirt modules hard to use.

I understand that the changes were applied for the sake of speed, but it seems less user friendly and could break the code written for previous versions.

Described ovirt*_info module behaviour was observed with ovirt 4.4, I doubt that ansible ovirt modules behaviour will be different with ovirt 4.3, for instance, but who knows...

1

There are 1 best solutions below

3
On

first thanks for the issue and to be honest I have it for some time in my head too.

Probably the easiest way to get all names of the nested attributes is to use the API. For example, you need to know the all possible attributes of the VMs template so you go to https://FQCN/api/vms/ID in there you get template href where you will see all the available attributes. Not the nices way but easiest.

I have few ideas on how to improve/solve this issue but I need to be careful to not break any backward compatibility.

So if you could please open an issue around this on GitHub repo [1] where we could have a discussion around this with other devs.

[1] http://github.com/ovirt/ovirt-ansible-collection