Fixed the ssl-certs in netbox plugin (#46543)

* Fixed the ssl-certs in netbox plugin

* Added validate_certs parameter and updated the example
pull/47246/head
nikkytub 6 years ago committed by John R Barker
parent 8a7a819040
commit 539f0fee09

@ -71,6 +71,7 @@ EXAMPLES = '''
plugin: netbox plugin: netbox
api_endpoint: http://localhost:8000 api_endpoint: http://localhost:8000
validate_certs: True
group_by: group_by:
- device_roles - device_roles
query_filters: query_filters:
@ -152,7 +153,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
NAME = 'netbox' NAME = 'netbox'
def _fetch_information(self, url): def _fetch_information(self, url):
response = open_url(url, headers=self.headers, timeout=self.timeout) response = open_url(url, headers=self.headers, timeout=self.timeout, validate_certs=self.validate_certs)
try: try:
raw_data = to_text(response.read(), errors='surrogate_or_strict') raw_data = to_text(response.read(), errors='surrogate_or_strict')
@ -427,6 +428,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
token = self.get_option("token") token = self.get_option("token")
self.api_endpoint = self.get_option("api_endpoint") self.api_endpoint = self.get_option("api_endpoint")
self.timeout = self.get_option("timeout") self.timeout = self.get_option("timeout")
self.validate_certs = self.get_option("validate_certs")
self.headers = { self.headers = {
'Authorization': "Token %s" % token, 'Authorization': "Token %s" % token,
'User-Agent': "ansible %s Python %s" % (ansible_version, python_version.split(' ')[0]), 'User-Agent': "ansible %s Python %s" % (ansible_version, python_version.split(' ')[0]),

Loading…
Cancel
Save