Folks,
For my needs, vsphere_guest didn’t quite fit the bill, and over time I’ve ended up re-writing most of the vsphere_guest functions into a separate module that I call ‘vcenter’, using pyvmomi.The reason for this was pysphere is poorly documented, and as I needed to add functionality, it was difficult to bake the functionality in (guest customizations, snapshots, cloning etc). pyvmomi matches the vsphere api, is backed by vmware, and the pyvmomi community has been extremely helpful. my module isn’t completely mature yet, but i’ve replaced all of what we were using vsphere_guest with the ‘vcenter’ module. i’d like to share my changes with the community, as I’ve heard a couple other folks on this list talk about using pyvmomi instead of pysphere for these kinds of things. I am thinking of making a couple of samples “clone_vm.yml” “snapshot_vm.yml” etc and pushing up to galaxy. It may take some time to get everything out of our repo, and into another one, and if there isn’t any interest i won’t bother. I at least thought I’d start the conversation here and see what comes of it.
Rewriting a module and having two modules is almost never a good solution as having one - can you talk about what features you needed and why you couldn’t use the existing library?
I would be interested in that targetted discussion.
The main motivation was to use pyvmomi, since it maps back to the vSphere API and, in my opinion, is more flexible than pysphere. instead of writing some functions in vsphere_guest that rely on pyvmomi, and some that rely on pysphere, i started a new module to accomplish the tasks that we need. Two main features that we required were cloning a vm from template instead of building new, and running vmware guest customizations on said template to give it IP addresses, etc. I understand that forking a module isn’t the most ideal, and I certainly tried to bake into vsphere_guest what I needed until I eventually started moving things into another module.
Thanks for opening up the dialog, i’d be interested to see what comes of it.
Dann
I’d still be interested if templates can be done well enough with the modules in place, but we do recognize we need to standardize on using one library.
Keeping the module “signature” for compat also important.
I’m not too concerned if method names are different from VMware’s official API, but am more concerned if certain things are not surfaced or there is a concern about how to update something is.
I did, at one time, have a clone function in the vsphere_guest module, and it worked well enough. One thing I never got working was guest customizations, that was the point where I started working with pyvmomi. I’m not sure how many people have a need to clone and customize like we do, though… We also do things like set a VMs uuid based on a uuid we have in a database, and set permissions on the VM object. (Things I was able to figure out how to do with pyvmomi but not pysphere)
I don’t think what I’ve come up with us impossible with pysphere, but since it isn’t as well documented as pyvmomi it was much faster for me to build what I needed.
I don’t know if maybe galaxy is a place for something like this or not? If not. That’s fine, too.
It could be – I’d like to avoid having “this one is better” things on Galaxy if possible.
This seems to imply if you want to propose replacing the module:
(A) a new module implementation with the same name that supports the exact same signatures as before, plus the new ones"
(B) hopefully also making the inventory script use the same language bindings at this time (and also keeping compatibility)
I will say we will prioritize this if this is done, so I’m not just asking for kicks – I’d really like to see template support by one patch or another. I personally don’t grok “guest customizations” as much – though I’m also curious if it could be made to work with the existing lib.
Understood. In the short term I may dig up my clone VM function and submit another PR to the existing module. I'd like to know how folks are using cloning in their environments, too. Reworking what I have to function like vsphere_guest may be difficult for me (biggest restraint being time) if someone wants to work with me on this I'd be willing to help out where I can.
Here is a public repo of what I've been working on.
As you can see, it's quite a bit different than vsphere_guest. Changing the module params is trivial enough, and I haven't done a lot of testing *without* guest customizations. In short, I hacked together something that fit my needs, and may have been a bit overly ambitious when I thought I could contribute back
There’s so much happening with Ansible these days that a tiny, incremental, adjustment/addition to a module is far, far likelier to make it through a pull request (shorter time to review, isn’t it). If you could just add the clone functionality Dann I think it would go through relatively quickly.
And I, for one, would be very happy to see it! (I’ve got an urgent use case :-))
I simply have a VM that is a template which I use as the basis for everything else in this given environment, and all I want to do is have Ansible manage spinning up new VMs based on that template. Makes for a smashing workflow in Tower then…