From fbdb448661e000f654e3365b9bac48e0a8013b8c Mon Sep 17 00:00:00 2001 From: Cougar Date: Tue, 13 Sep 2016 21:03:08 +0300 Subject: [PATCH] vmware_guest Fix: remove 'nic' and 'disk' requirements for facts (#2844) --- cloud/vmware/vmware_guest.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cloud/vmware/vmware_guest.py b/cloud/vmware/vmware_guest.py index 43082e83343..23e25d0453f 100644 --- a/cloud/vmware/vmware_guest.py +++ b/cloud/vmware/vmware_guest.py @@ -72,7 +72,7 @@ options: nic: description: - A list of nics to add - required: True + required: False wait_for_ip_address: description: - Wait until vcenter detects an IP address for the guest @@ -94,6 +94,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' Example from Ansible playbook +# +# Crate VM from template +# - name: create the VM vmware_guest: validate_certs: False @@ -121,6 +124,19 @@ Example from Ansible playbook template: template_el7 wait_for_ip_address: yes 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 = """ @@ -468,6 +484,9 @@ class PyVmomiHelper(object): 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 = get_obj(self.content, [vim.Datastore], datastore_name) @@ -795,8 +814,8 @@ def main(): name_match=dict(required=False, type='str', default='first'), uuid=dict(required=False, type='str'), folder=dict(required=False, type='str', default=None, aliases=['folder']), - disk=dict(required=True, type='list'), - nic=dict(required=True, type='list'), + disk=dict(required=False, type='list'), + nic=dict(required=False, type='list'), hardware=dict(required=False, type='dict', default={}), force=dict(required=False, type='bool', default=False), datacenter=dict(required=False, type='str', default=None),