1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

slack: Add validate_certs option in plugin (#46567)

This fix adds a configurable parameter for slack plugin.

Fixes: #45682

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-11-15 20:45:27 +05:30 committed by Matt Martz
parent 87d10b9b78
commit f0c290c930

View file

@ -42,6 +42,16 @@ DOCUMENTATION = '''
ini:
- section: callback_slack
key: username
validate_certs:
description: validate the SSL certificate of the Slack server. (For HTTPS URLs)
version_added: "2.8"
env:
- name: SLACK_VALIDATE_CERTS
ini:
- section: callback_slack
key: validate_certs
default: True
type: bool
'''
import json
@ -100,6 +110,7 @@ class CallbackModule(CallbackBase):
self.channel = self.get_option('channel')
self.username = self.get_option('username')
self.show_invocation = (self._display.verbosity > 1)
self.validate_certs = self.get_option('validate_certs')
if self.webhook_url is None:
self.disabled = True
@ -122,7 +133,7 @@ class CallbackModule(CallbackBase):
self._display.debug(data)
self._display.debug(self.webhook_url)
try:
response = open_url(self.webhook_url, data=data)
response = open_url(self.webhook_url, data=data, validate_certs=self.validate_certs)
return response.read()
except Exception as e:
self._display.warning(u'Could not submit message to Slack: %s' %