From bc834ff5649749392d770cdb35c112394f2c0900 Mon Sep 17 00:00:00 2001 From: Jason Kohles Date: Wed, 10 Feb 2016 12:42:44 -0500 Subject: [PATCH] Enable env vars for vsphere_guest This commit allows the connection information for the vsphere_guest module to be provided as environment variables, which makes it possible to use Cloud Credentials from Ansible Tower in playbooks that utilize vsphere_guest. | ENV VAR | vsphere_guest param | | --------------- | ---------------------- | | VMWARE_HOST | vcenter_hostname | | VMWARE_USER | username | | VMWARE_PASSWORD | password | --- lib/ansible/modules/cloud/vmware/vsphere_guest.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py index 9ca2908edff..4e82cb4d939 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -1604,9 +1604,18 @@ def main(): module = AnsibleModule( argument_spec=dict( - vcenter_hostname=dict(required=True, type='str'), - username=dict(required=True, type='str'), - password=dict(required=True, type='str', no_log=True), + vcenter_hostname=dict( + type='str', + default=os.environ['VMWARE_HOST'] + ), + username=dict( + type='str', + default=os.environ['VMWARE_USER'] + ), + password=dict( + type='str', no_log=True, + default=os.environ['VMWARE_PASSWORD'] + ), state=dict( required=False, choices=[