Modifying vsphere_guest

Hi all,

I am trying the reproduce the same as mentioned in

https://github.com/romeotheriault/ansible-vsphere_guest

Ansible module that allows you to define and create a VMWare vsphere guest OS instance which can then be booted to start an automated install.

I have created playbook file similarly.
while executing it i am getting the following error.

tarun@ubuntu:~/playbooks$ ansible-playbook install_VM_test.yml -vvvv
[WARNING]: provided hosts list is empty, only localhost is available

PLAY [127.0.0.1] **************************************************************

TASK: [vsphere_guest ] ********************************************************
<127.0.0.1> REMOTE_MODULE vsphere_guest vcenter_hostname=10.39.1.59 password=VALUE_HIDDEN datastore=10_39_1_59_datastore1 esxi_hostname=esx-dev.hw-lab-pxe.inca.infoblox.com user=root guestosid=ubuntu64Guest vm_notes=test guest=newTestVM datacenter=ha-datacenter
<127.0.0.1> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1432331320.78-272982991862969 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1432331320.78-272982991862969 && echo $HOME/.ansible/tmp/ansible-tmp-1432331320.78-272982991862969’]
<127.0.0.1> PUT /tmp/tmp8bwjcs TO /home/tarun/.ansible/tmp/ansible-tmp-1432331320.78-272982991862969/vsphere_guest
<127.0.0.1> EXEC [‘/bin/sh’, ‘-c’, u’LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/tarun/.ansible/tmp/ansible-tmp-1432331320.78-272982991862969/vsphere_guest; rm -rf /home/tarun/.ansible/tmp/ansible-tmp-1432331320.78-272982991862969/ >/dev/null 2>&1’]
failed: [127.0.0.1] => {“failed”: true}
msg: unsupported parameter for module: power_on

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/tarun/install_VM_test.retry

127.0.0.1 : ok=0 changed=0 unreachable=0 failed=1

I am using the same vsphere_guest provided in above link…
Should i include vsphere_guest.py file in ansible module or configure it in plugins?

Please help me. I am new to ansible.

Thanks

Hi Tarun,

Please check the ‘state’ parameter for the module in your playbook - it should be powered_on, not power_on.

No Mikhail, I am using those parameters in my vsphere_guest module. I am trying to add new parameters like power_on, vm_cdrom etc and have done the changes needed in vsphere_guest as shown in https://github.com/romeotheriault/ansible-vsphere_guest

But while i am executing this playbook, ansible is not picking from my updated vsphere_guest. I want to know how to add my new module to ansible( vsphere_guest) so that i can achieve my goal.?

I would suggest to rename you custom module to distinguish it from the stock one. Let’s say the module name would be vsphere_guest_custom. Create ‘library’ subdir in the same directory where your playbooks reside and put vsphere_guest_custom.py there.

Then you can call it from playbook as

`
vsphere_guest_custom:

`
or

`
local_action:
module_name: vsphere_guest_custom
:

`

That works…Thanks a lot. This group is helping me a lot.