Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[check_consul] add SSL support to Consul checks. #2034

Merged
merged 1 commit into from
Nov 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion checks.d/consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ def __init__(self, name, init_config, agentConfig, instances=None):
def consul_request(self, instance, endpoint):
url = urljoin(instance.get('url'), endpoint)
try:
resp = requests.get(url)

clientcertfile = instance.get('client_cert_file', self.init_config.get('client_cert_file', False))
privatekeyfile = instance.get('private_key_file', self.init_config.get('private_key_file', False))
cabundlefile = instance.get('ca_bundle_file', self.init_config.get('ca_bundle_file', True))

if clientcertfile:
if privatekeyfile:
resp = requests.get(url, cert=(clientcertfile,privatekeyfile), verify=cabundlefile)
else:
resp = requests.get(url, cert=clientcertfile, verify=cabundlefile)
else:
resp = requests.get(url, verify=cabundlefile)

except requests.exceptions.Timeout:
self.log.exception('Consul request to {0} timed out'.format(url))
raise
Expand Down
15 changes: 15 additions & 0 deletions conf.d/consul.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,23 @@ init_config:

instances:
# Where your Consul HTTP Server Lives
# Remind to use https instead of http if your Consul setup is configured to do so.
- url: http://localhost:8500

# If Consul setup uses SSL, you might need to set the following options as well.

# You can specify a local cert to use as client side certificate
# as a single file (containing the private key and the certificate concatenated)
# client_cert_file: '/path/to/client.concatenated.pem'

# Or as two separate files (for certificate and key):
# client_cert_file: '/path/to/client.cert.pem'
# private_key_file: '/path/to/private.key.pem'

# Whether to verifiy SSL certificates for HTTPS requests.
# Possible values: True, False or '/path/to/your/trusted_ca_bundle_file'
# ca_bundle_file: '/path/to/trusted_ca_bundle_file'

# Whether to perform checks against the Consul service Catalog
catalog_checks: yes

Expand Down