From 80d8277521c81a16fca8bcfe78d14d144489ecf6 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 | --- cloud/vmware/vsphere_guest.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cloud/vmware/vsphere_guest.py b/cloud/vmware/vsphere_guest.py index 7d9d20d51dd..c245671d1c2 100644 --- a/cloud/vmware/vsphere_guest.py +++ b/cloud/vmware/vsphere_guest.py @@ -1562,9 +1562,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=[