I’d like to get an overview of what exists so far when it comes to a module for vmware.
We definitely need this, and I might give it a try. I can’t give a time frame on when I could work on this, as it’s something I’ll propbably work on in my own time, but I hope to get at least something basic starting in the coming weeks/month.
The only really interesting, existing base I know about is the stuff in the ansible-provisioning project (https://github.com/ansible-provisioning/ansible-provisioning), notably the vsphere_* modules in library/. AFAICS it seems to me the pysphere module is the way to go.
If someone has the same plans, or already started working on something, i’d very much like to hear about it.
In the mean time, it would be interesting to hear ideas on the subject, on implementation details, etc.
Not sure why the ansible-provisioning modules are split into different modules btw. Whilst the other two seem definitely to be ‘not finished’, vsphere_boot is a good start, as a more general module.
What I need in the first place, feature wise is
create a guest, with all the parameters like on would conigure in the GUI (procs, memory, storage, nic’s, …)
start the guest and let it do a pxe boot the first time
reconfigure, at least be able to remove a nic (for when we pxe boot a dedicated nic)
It does a lot of the items you’ve ticked off, but doesn’t currently handle changing VM parameters once the VM is created or destroying the VM. (Let’s just say the vmware api is not pretty.)
I’m taking another approach to automating the guest install. Instead of PXE booting I’m creating a custom network install boot iso with the templated kickstart file on it, and attaching that iso to the VM on creation. (This is an idea I got from Dag @ ansible-provisioning.)
I’ve been meaning to work on the module more to make it more generally consumable and maybe eventually integrated into core but have been busy getting our work VM creation workflow redesigned to use this. I’m open to working on it though. Would be interested in your thoughts.
I would very much like to be able to see a VMware ESX capable, similar-to-EC2-and-rax-modules system in core. (Aka returns things usable by add_hosts in the instances hash?)
(Is it also possible to do a VMware inventory plugin?)
I’d generally like to see something that is able to create a guest that can at least PXE boot, or do kernel+initrd + boot parameters, either way.
I generally think having to create a boot ISO should be unneccessary, and baking in the kickstart file is unneccessary as the kickstart could be dynamically served up by any one of many systems, including
Cobbler (http://cobblerd.org)*
I think for core inclusion it has to support more than just the boot media approach, since a lot about Ansible should be to get away from the need to spin images, though we can certaintly take over after images are deployed.
–Michael
= disclaimer, wrote this some years ago, now not maintained by AnsibleWorks but in the excellent hands of James Cammarata, and you should check it out!
Out of curiosity, is kernel+initrd+commandline also possible?
These may be suitable for core inclusion, the above is not a prereq, but it would be nice if it could avoid a PXE environment (in case one already existed and we wanted to ignore it).
(I believe when I last asked they only did the ISO, or the playbooks that referenced them required doing ISO builds.)
Out of curiosity, is kernel+initrd+commandline also possible?
I doubt vsphere can do that.
These may be suitable for core inclusion, the above is not a prereq, but it
would be nice if it could avoid a PXE environment (in case one already
existed and we wanted to ignore it).
That's why we use ISO media. It's the only common thing all hardware/hypervisors can do properly. (ESX, KVM, iLO, RSA, RHEV)
(I believe when I last asked they only did the ISO, or the playbooks that
referenced them required doing ISO builds.)
No, vsphere only did PXE because I never got the administrative rights on vSphere to:
1. change the boot order
2. have an NFS datastore or push images to another datastore
You made conclusions based only on the examples I showed using ISO images. And despite me mentioning that we use ISO just because it makes the most sense in our environment. But PXE is supported for all *_boot modules (it just isn't possible in heterogenous environments or disabled by security in most large companies I have worked)
If you looked at the module documentation it's clear you can do PXE with all of them. (media=network)
I have a vsphere_clone module I would like to contribute (amongst others). My only concern is that I have added async support to the module since this is part of PySphere functionality. This allows the use of a boolean to indicate asynchronous vs synchronous(the default) in order to cooperate with loops and nested loops in Ansible (which we all know do not support Async at this point in time). In the spirit of keeping the functionality of PySphere, I have kept this option available and find it quite powerful.
Would this be acceptable, if yes… then I will perform a pull request or whatever is necessary to contribute.
Sounds like we’d be interested in taking a look at least, and a PR is a good way to get that in the queue. I will admit now the queue is quite longish as we’re powering through things the best we can.
I imagine if async is not used, it’s a blocking operation, and the async operation in ansible would be needed to use with it, and that might be worth noting in docs?
In looking at my original proposal, I think combining two unique implementations of Async functionality is going to be a bad idea, if not for being difficult to troubleshoot and impossible to test, for being a bad design.
Instead, I would like to suggest not using PySphere Async support and have Ansible handle Async via it’s own mechanism 100%. While it will prevent having the ability to use Async while using with_items and with_nested, it would be consistent with other modules and if this were to ever become a supported feature, no changes would be necessary for the cloning module.
Furthermore, when using the vSphere API for Async tasks, it has it’s own queue and comes with it’s own set of issues. Such as the queue filling, tracking the many statuses it supports, additional network calls to get status, implementing additional timeouts, etc.
After I make and test this change, I will do a pull request… with the assumption you believe this is a cleaner implementation.
Hi, I’m new to ansible and vmware and came across this post which is exactly what I need to do. Forgive me if this is answered elsewhere, but is there a way to configure the vsphere_guest module to clone a virtual machine or start a virtual machine from a template?
We currently use this to manage our datacenter of test and development vms. It uses pyvmomi which is VMWares python library for interacting with the vsphere api.
It currently has support for:
Create, Clone ( from templates as well ), Delete VMs
Create, Remove, and Revert to VM snapshots
Create, Remove Inventory Folders
Interact with the Guest Operations Manager.
So in order to get support for all those different things, I came up with a way to convert a “spec” object into pyvmomi objects. This allows me to call roughly any function on a Managed Object Reference. I hope it is not too confusing and the documentation is clear. I gave examples but there is likely more that the module is capable of than the examples I gave. My hope is that this module could be one day included in the core Ansible project.