community.vmware icon indicating copy to clipboard operation
community.vmware copied to clipboard

Ansible - Export-LcmClusterDesiredState

Open nebb00 opened this issue 2 years ago • 11 comments

Add the functionailty to export LCM cluster state including JSON and ISO exactly like the PowerCLI cmdlet using Ansible

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/export-lcmclusterdesiredstate/#Default

nebb00 avatar Oct 24 '23 08:10 nebb00

It looks like Settings Clusters Software APIs can be used to implement this.

However, since this is the REST instead of the old SOAP API, it might be better to implement this in vmware.vmware_rest which is focused on it. On the other hand, there isn't much work done in this collection and I didn't figure out yet how to implement new modules there.

Well, at the moment the priority is to release community.vmware 4.0.0. We'll try to have a look at this once this is done.

mariolenz avatar Oct 24 '23 12:10 mariolenz

@mariolenz I studied a little how ansible_builder works, which automatically builds the vmware.vmware_rest collection. First of all, she needs swagger files describing the api in the openapi 3.0 format. These APIs are not publicly available anywhere, which means they are most likely either written manually (with which I have experience) or some other way. then they are generated in this way (I came across a project for generating json with openapi by bypassing vcsa endpoints, but it did not work correctly for me).

ihumster avatar Oct 24 '23 12:10 ihumster

Yes, that's been the first problem I didn't understand: Where to get the Swagger / OpenAPI definitions for the API?

Well, maybe I'll find the time to have a closer look at this when 4.0.0 is released. That is, if there isn't too much to do in this collection.

mariolenz avatar Oct 24 '23 12:10 mariolenz

We have some modules, based on VmwareRestClient class. And theoretically, you can create a new module on it to implement the above capabilities. But we will slide into duplicating collections...

ihumster avatar Oct 24 '23 12:10 ihumster

@nebb00 I don't understand why you only want to get the cluster image. While we're at it, I think we should also try to implement setting it ;-)

This way, you could manage it via ansible. If you have a lot of clusters and want them to have the same cluster image, it can be pretty annoying to configure this manually...

cc @JoschuaA4

mariolenz avatar Oct 30 '23 16:10 mariolenz

These APIs are not publicly available anywhere, which means they are most likely either written manually (with which I have experience) or some other way.

I think we could get he spec with vmware-openapi-generator.

I've tried to do it in ansible-collections/vmware.vmware_rest#443, but am not sure if this is really correct.

mariolenz avatar Nov 18 '23 15:11 mariolenz

@mariolenz I couldn't get it to work. Or I don’t understand how to configure it correctly.

ihumster avatar Nov 18 '23 17:11 ihumster

@ihumster Maybe you could add what you tried and the problems you ran into to ansible-collections/vmware.vmware_rest#443 so we don't clutter this issue.

mariolenz avatar Nov 19 '23 13:11 mariolenz

I think this is quite similar to #1005

mariolenz avatar Dec 05 '23 19:12 mariolenz

Maybe we can use something from com.vmware.esx.settings.clusters to do this :thinking:

mariolenz avatar Dec 26 '23 12:12 mariolenz

I've ended up using the API to do what I want

nebb00 avatar Dec 26 '23 12:12 nebb00