Skip to content

Commit

Permalink
PuppetDB backend: allow to override URL scheme in config
Browse files Browse the repository at this point in the history
* In some environments the PuppetDB hosts might listen only on HTTP on
  localhost and the Cumin host might connect to it via an SSH tunnel.
* Allow to override the default HTTPS scheme of the PuppetDB URL in the
  configuration.

Bug: T218441
Change-Id: I14ecd78cf2652fb11eb471f8597c57db1321cb98
  • Loading branch information
anarcat authored and volans- committed Mar 21, 2019
1 parent 2e58521 commit 8e49a21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cumin/backends/puppetdb.py
Expand Up @@ -135,7 +135,7 @@ class PuppetDBQuery(BaseQuery):
``host10[10-42].*.domain or (not F:key1 = value1 and host10*) or (F:key2 > value2 and F:key3 ~ '^value[0-9]+')``
"""

base_url_template = 'https://{host}:{port}'
base_url_template = '{scheme}://{host}:{port}'
""":py:class:`str`: string template in the :py:meth:`str.format` style used to generate the base URL of the
PuppetDB server."""

Expand All @@ -162,6 +162,7 @@ def __init__(self, config):
self._endpoint = None
puppetdb_config = self.config.get('puppetdb', {})
base_url = self.base_url_template.format(
scheme=puppetdb_config.get('scheme', 'https'),
host=puppetdb_config.get('host', 'localhost'),
port=puppetdb_config.get('port', 443))

Expand Down
3 changes: 3 additions & 0 deletions doc/examples/config.yaml
Expand Up @@ -16,6 +16,9 @@ environment:
puppetdb:
host: puppetdb.local
port: 443
# [optional[ Allow to override the default HTTPS scheme with HTTP in case the connection to PuppetDB is secured in
# other ways (e.g. SSH tunnel)
scheme: https
api_version: 4 # Supported versions are v3 and v4. If not specified, v4 will be used.
urllib3_disable_warnings: # List of Python urllib3 exceptions to ignore
- SubjectAltNameWarning
Expand Down

0 comments on commit 8e49a21

Please sign in to comment.