Add validate_certs param to bigip_* modules

Ignoring SSL cert verification may be necessary when testing with a
server that has a self-signed certificate.

See
https://github.com/ansible/ansible-modules-extras/pull/288#issuecomment-85196736
This commit is contained in:
Marc Abramowitz
2015-03-23 14:26:11 -07:00
committed by Matt Clay
parent bad5666c9e
commit 128cf5fd74
6 changed files with 118 additions and 0 deletions

View File

@@ -54,6 +54,14 @@ options:
default: null
choices: []
aliases: []
validate_certs:
description:
- If C(no), SSL certificates will not be validated. This should only be used
on personally controlled sites using self-signed certificates.
required: false
default: 'yes'
choices: ['yes', 'no']
version_added: 1.9.1
state:
description:
- Pool member state
@@ -154,6 +162,12 @@ def bigip_api(bigip, user, password):
api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)
return api
def disable_ssl_cert_validation():
# You probably only want to do this for testing and never in production.
# From https://www.python.org/dev/peps/pep-0476/#id29
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
def node_exists(api, address):
# hack to determine if node exists
result = False
@@ -212,6 +226,7 @@ def main():
server = dict(type='str', required=True),
user = dict(type='str', required=True),
password = dict(type='str', required=True),
validate_certs = dict(default='yes', type='bool'),
state = dict(type='str', default='present', choices=['present', 'absent']),
partition = dict(type='str', default='Common'),
name = dict(type='str', required=True),
@@ -227,6 +242,7 @@ def main():
server = module.params['server']
user = module.params['user']
password = module.params['password']
validate_certs = module.params['validate_certs']
state = module.params['state']
partition = module.params['partition']
host = module.params['host']
@@ -234,6 +250,9 @@ def main():
address = "/%s/%s" % (partition, name)
description = module.params['description']
if not validate_certs:
disable_ssl_cert_validation()
if state == 'absent' and host is not None:
module.fail_json(msg="host parameter invalid when state=absent")