Well it's unfortunate that their is so duplicated functionality. I actually
started this before that module was part of core, and when it finally did
get added to core it did not meet my needs. That said my module does a lot
more than the one in core. Like I said before you can manage VM snapshots,
and interact with the guest operations manager which I use to reconfigure
the networking on the devices after I clone the VMs. My module can also
power the VMs on and off.
Unfortunately my module does not provide good output after the tasks, and I
really could use some help extending it.
As for attaching volumes I have never done that but I think you should be
able too. Are you talking about attaching them during a Clone or Create
process or attaching a volume to an existing VM?
I think something like this should work. If you look at the spec values
they match up to the vsphere API identically. The spec type is the name of
a function to run on the guest managed object and the value of the spec is
the parameters to that function ( which in this case happens to be called
spec ). You do need to fill in any required fields for those objects, which
are specified in the vmware documenation.
-name:attach volume
local_action:
module:vsphere
guest:
name:test
state: running
action: task
spec:
type: ReconfigVM_Task
value:
spec:
VirtualMachineConfigSpec :
deviceChange:
- VirtualDeviceConfigSpec:
operation: add
device:
VirtualDisk:
diskObjectId: <id of existing virtual disk>
On Wednesday, August 20, 2014 6:40:58 PM UTC-7, Michael DeHaan wrote:
>
> Can I ask what's intended to be different from the module we already have
> in core?
>
> http://docs.ansible.com/vsphere_guest_module.html
>
>
>
>
> On Wed, Aug 20, 2014 at 9:27 PM, kesten broughton <[email protected]
> <javascript:>> wrote:
>
>> Nice work! That's half my battle,
>> the rest is attaching volumes.
>>
>> Does your module support that sort of thing?
>> How would you extend to do that?
>>
>> kesten
>>
>>
>> On Wed, Aug 20, 2014 at 7:18 PM, Tony Kinsley <[email protected]
>> <javascript:>> wrote:
>>
>>> I actually recently got approval to release a module I wrote to manage
>>> vsphere. You can find it at https://github.com/ViaSat/ansible-vsphere
>>>
>>> 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.
>>>
>>> Let me know what you think.
>>> Tony
>>>
>>> On Tuesday, August 5, 2014 1:53:03 PM UTC-7, Jamal B wrote:
>>>>
>>>> Hi, is there a chance that cloning will be added to the vsphere_guest
>>>> module in an upcoming release?
>>>>
>>>> On Thursday, July 10, 2014 9:08:23 AM UTC-4, kesten broughton wrote:
>>>>>
>>>>> I would agree, cloning functionality belongs in vsphere_guest module
>>>>> if possible.
>>>>>
>>>>> On Wednesday, July 9, 2014 4:30:32 PM UTC-5, Michael DeHaan wrote:
>>>>>>
>>>>>> It seems in this case we should try to work the features into the
>>>>>> existing module, since they are both about creating guests?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Jul 9, 2014 at 3:54 PM, kesten broughton <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> I was referring to the vsphere_clone mentioned, not vsphere_guest
>>>>>>> which is in trunk https://github.com/ansible/ansible/tree/devel/
>>>>>>> library/cloud
>>>>>>>
>>>>>>> As far as i can tell, vsphere_guest currently only supports creating
>>>>>>> a vm from .iso
>>>>>>>
>>>>>>> What i really need is creating clones from a template.
>>>>>>>
>>>>>>> k
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jul 9, 2014 at 2:47 PM, Michael DeHaan <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> This is actually already in core.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Jul 9, 2014 at 8:11 AM, kesten broughton <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> If you've got a public git branch, i can help with testing and
>>>>>>>>> documentation.
>>>>>>>>> I've worked with pysphere a bit.
>>>>>>>>>
>>>>>>>>> kesten
>>>>>>>>>
>>>>>>>>> On Tuesday, July 8, 2014 6:23:06 PM UTC-5, Corey Gaffney wrote:
>>>>>>>>>
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> -Corey
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Tue, Jul 8, 2014 at 5:30 PM, Michael DeHaan <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> 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?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Tue, Jul 8, 2014 at 2:34 AM, Corey Gaffney <[email protected]>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> 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.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>> Corey
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Friday, April 19, 2013 5:36:47 PM UTC-5, Michael DeHaan
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Documentation was somewhat short at the time, we're talking
>>>>>>>>>>>>> about it now, it's all good :)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Apr 19, 2013 at 6:01 PM, Dag Wieers <[email protected]>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, 19 Apr 2013, Michael DeHaan wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Ok, that's good.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 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)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> -- dag wieers, [email protected], http://dag.wieers.com/
>>>>>>>>>>>>>> -- dagit linux solutions, [email protected], http://dagit.net/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> [Any errors in spelling, tact or fact are transmission errors]
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>>>>> Google Groups "Ansible Project" group.
>>>>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from
>>>>>>>>>>>>>> it, send an email to [email protected].
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> For more options, visit https://groups.google.com/grou
>>>>>>>>>>>>>> ps/opt_out.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Michael DeHaan <[email protected]>
>>>>>>>>>>>>>
>>>>>>>>>>>>> CTO, AnsibleWorks, Inc.
>>>>>>>>>>>>> http://www.ansibleworks.com/
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>>> Google Groups "Ansible Project" group.
>>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from
>>>>>>>>>>>> it, send an email to [email protected].
>>>>>>>>>>>> To post to this group, send email to ansible...@googlegroups.
>>>>>>>>>>>> com.
>>>>>>>>>>>>
>>>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>>>> https://groups.google.com/d/msgid/ansible-project/9e0fc804-
>>>>>>>>>>>> 8a2d-4923-bc32-feacb183c472%40googlegroups.com
>>>>>>>>>>>> <https://groups.google.com/d/msgid/ansible-project/9e0fc804-8a2d-4923-bc32-feacb183c472%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>>>>> .
>>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> You received this message because you are subscribed to a topic
>>>>>>>>>>> in the Google Groups "Ansible Project" group.
>>>>>>>>>>> To unsubscribe from this topic, visit
>>>>>>>>>>> https://groups.google.com/d/topic/ansible-project/33hmOR301Y
>>>>>>>>>>> I/unsubscribe.
>>>>>>>>>>> To unsubscribe from this group and all its topics, send an
>>>>>>>>>>> email to [email protected].
>>>>>>>>>>> To post to this group, send email to [email protected]
>>>>>>>>>>> .
>>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>>> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgy
>>>>>>>>>>> yZt9RKyaHUOC5Ji%2BhCVsZswbkCe8TPSDo0PSoYg9K3Q%40mail.gmail.com
>>>>>>>>>>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgyyZt9RKyaHUOC5Ji%2BhCVsZswbkCe8TPSDo0PSoYg9K3Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>>>>>> .
>>>>>>>>>>>
>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "Ansible Project" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> send an email to [email protected].
>>>>>>>>>
>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>> To view this discussion on the web visit
>>>>>>>>> https://groups.google.com/d/msgid/ansible-project/
>>>>>>>>> 2f18a176-4a1e-42de-85de-28056ce51b83%40googlegroups.com
>>>>>>>>> <https://groups.google.com/d/msgid/ansible-project/2f18a176-4a1e-42de-85de-28056ce51b83%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>> .
>>>>>>>>>
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>>> the Google Groups "Ansible Project" group.
>>>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>>>>>> topic/ansible-project/33hmOR301YI/unsubscribe.
>>>>>>>> To unsubscribe from this group and all its topics, send an email
>>>>>>>> to [email protected].
>>>>>>>>
>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzA4TN_
>>>>>>>> dX5eLciswrWQXUBk77%3DU1RSPn3UC5vPCOhAG_Q%40mail.gmail.com
>>>>>>>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzA4TN_dX5eLciswrWQXUBk77%3DU1RSPn3UC5vPCOhAG_Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Ansible Project" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/ansible-project/CAK5UeTu4Nd%
>>>>>>> 3DNVAXTcZ44Liv6jsCKF83LpDRtp8NM_8OxK6FZnA%40mail.gmail.com
>>>>>>> <https://groups.google.com/d/msgid/ansible-project/CAK5UeTu4Nd%3DNVAXTcZ44Liv6jsCKF83LpDRtp8NM_8OxK6FZnA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Ansible Project" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/ansible-project/33hmOR301YI/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected] <javascript:>.
>>>
>>> To post to this group, send email to [email protected]
>>> <javascript:>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/8f6fe9e8-ed97-4fba-82cf-429272968d6d%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/ansible-project/8f6fe9e8-ed97-4fba-82cf-429272968d6d%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAK5UeTvnmL%2Bju7Nb%2B0VOQ%3DjOpDRHTDKHFL%3DcWRKf4jDBEf_4oA%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/CAK5UeTvnmL%2Bju7Nb%2B0VOQ%3DjOpDRHTDKHFL%3DcWRKf4jDBEf_4oA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1b796f24-bbfa-4675-a259-90a0562403bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.