vmware_guest Fix: remove 'nic' and 'disk' requirements for facts (#2844)

This commit is contained in:
Cougar 2016-09-13 21:03:08 +03:00 committed by Matt Clay
parent ac72df08dd
commit 7dbdadb396

View file

@ -72,7 +72,7 @@ options:
nic: nic:
description: description:
- A list of nics to add - A list of nics to add
required: True required: False
wait_for_ip_address: wait_for_ip_address:
description: description:
- Wait until vcenter detects an IP address for the guest - Wait until vcenter detects an IP address for the guest
@ -94,6 +94,9 @@ extends_documentation_fragment: vmware.documentation
EXAMPLES = ''' EXAMPLES = '''
Example from Ansible playbook Example from Ansible playbook
#
# Crate VM from template
#
- name: create the VM - name: create the VM
vmware_guest: vmware_guest:
validate_certs: False validate_certs: False
@ -121,6 +124,19 @@ Example from Ansible playbook
template: template_el7 template: template_el7
wait_for_ip_address: yes wait_for_ip_address: yes
register: deploy register: deploy
#
# Gather facts only
#
- name: gather the VM facts
vmware_guest:
validate_certs: False
hostname: 192.168.1.209
username: administrator@vsphere.local
password: vmware
name: testvm_2
esxi_hostname: 192.168.1.117
register: facts
''' '''
RETURN = """ RETURN = """
@ -476,6 +492,9 @@ class PyVmomiHelper(object):
self.params['folder'] self.params['folder']
) )
if not 'disk' in self.params:
return ({'changed': False, 'failed': True, 'msg': "'disk' is required for VM deployment"})
datastore_name = self.params['disk'][0]['datastore'] datastore_name = self.params['disk'][0]['datastore']
datastore = get_obj(self.content, [vim.Datastore], datastore_name) datastore = get_obj(self.content, [vim.Datastore], datastore_name)
@ -803,8 +822,8 @@ def main():
name_match=dict(required=False, type='str', default='first'), name_match=dict(required=False, type='str', default='first'),
uuid=dict(required=False, type='str'), uuid=dict(required=False, type='str'),
folder=dict(required=False, type='str', default=None, aliases=['folder']), folder=dict(required=False, type='str', default=None, aliases=['folder']),
disk=dict(required=True, type='list'), disk=dict(required=False, type='list'),
nic=dict(required=True, type='list'), nic=dict(required=False, type='list'),
hardware=dict(required=False, type='dict', default={}), hardware=dict(required=False, type='dict', default={}),
force=dict(required=False, type='bool', default=False), force=dict(required=False, type='bool', default=False),
datacenter=dict(required=False, type='str', default=None), datacenter=dict(required=False, type='str', default=None),