mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added support for insecure parameter
This commit is contained in:
parent
697980d7cc
commit
2f79e2c01c
1 changed files with 16 additions and 0 deletions
|
@ -34,6 +34,8 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
import ssl
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: vsphere_guest
|
module: vsphere_guest
|
||||||
|
@ -48,6 +50,11 @@ options:
|
||||||
required: true
|
required: true
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
aliases: []
|
||||||
|
insecure:
|
||||||
|
description:
|
||||||
|
- Ignore SSL verification errors when connection to vcenter
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
guest:
|
guest:
|
||||||
description:
|
description:
|
||||||
- The virtual server name you wish to manage.
|
- The virtual server name you wish to manage.
|
||||||
|
@ -1574,6 +1581,7 @@ def main():
|
||||||
cluster=dict(required=False, default=None, type='str'),
|
cluster=dict(required=False, default=None, type='str'),
|
||||||
force=dict(required=False, type='bool', default=False),
|
force=dict(required=False, type='bool', default=False),
|
||||||
esxi=dict(required=False, type='dict', default={}),
|
esxi=dict(required=False, type='dict', default={}),
|
||||||
|
insecure=dict(required=False, type='bool', default=False),
|
||||||
power_on_after_clone=dict(required=False, type='bool', default=True)
|
power_on_after_clone=dict(required=False, type='bool', default=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1615,12 +1623,20 @@ def main():
|
||||||
from_template = module.params['from_template']
|
from_template = module.params['from_template']
|
||||||
snapshot_to_clone = module.params['snapshot_to_clone']
|
snapshot_to_clone = module.params['snapshot_to_clone']
|
||||||
power_on_after_clone = module.params['power_on_after_clone']
|
power_on_after_clone = module.params['power_on_after_clone']
|
||||||
|
insecure = module.params['insecure']
|
||||||
|
|
||||||
|
|
||||||
# CONNECT TO THE SERVER
|
# CONNECT TO THE SERVER
|
||||||
viserver = VIServer()
|
viserver = VIServer()
|
||||||
try:
|
try:
|
||||||
viserver.connect(vcenter_hostname, username, password)
|
viserver.connect(vcenter_hostname, username, password)
|
||||||
|
except ssl.SSLError as sslerr:
|
||||||
|
if '[SSL: CERTIFICATE_VERIFY_FAILED]' in sslerr.strerror and insecure:
|
||||||
|
default_context = ssl._create_default_https_context
|
||||||
|
ssl._create_default_https_context = ssl._create_unverified_context
|
||||||
|
viserver.connect(vcenter_hostname, username, password)
|
||||||
|
else:
|
||||||
|
raise Exception(sslerr)
|
||||||
except VIApiException, err:
|
except VIApiException, err:
|
||||||
module.fail_json(msg="Cannot connect to %s: %s" %
|
module.fail_json(msg="Cannot connect to %s: %s" %
|
||||||
(vcenter_hostname, err))
|
(vcenter_hostname, err))
|
||||||
|
|
Loading…
Reference in a new issue