From 7197c41fff879b776ff41291d7f73cf345964236 Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Mon, 2 Sep 2019 22:17:25 +0200 Subject: [PATCH] influxdb: Add support for 'path' parameter (#61173) While it's possible to host InfluxDB on a different path prefix (through a reverse proxy such as nginx or traefik), the Ansible influxdb_* modules did't support that use case. The patch adds a 'path' parameter, which is passed to the influxdb Python client. Example for connecting to InfluxDB running on http://localhost/influxdb - hosts: all tasks: - influxdb_database: database_name: test path: influxdb port: 80 --- lib/ansible/module_utils/influxdb.py | 3 +++ lib/ansible/plugins/doc_fragments/influxdb.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/ansible/module_utils/influxdb.py b/lib/ansible/module_utils/influxdb.py index 3278b6469fa..8f54a22e5c2 100644 --- a/lib/ansible/module_utils/influxdb.py +++ b/lib/ansible/module_utils/influxdb.py @@ -36,6 +36,7 @@ class InfluxDb(): self.check_lib() self.hostname = self.params['hostname'] self.port = self.params['port'] + self.path = self.params['path'] self.username = self.params['username'] self.password = self.params['password'] self.database_name = self.params.get('database_name') @@ -52,6 +53,7 @@ class InfluxDb(): return dict( hostname=dict(type='str', default='localhost'), port=dict(type='int', default=8086), + path=dict(type='str', default=''), username=dict(type='str', default='root', aliases=['login_username']), password=dict(type='str', default='root', no_log=True, aliases=['login_password']), ssl=dict(type='bool', default=False), @@ -67,6 +69,7 @@ class InfluxDb(): args = dict( host=self.hostname, port=self.port, + path=self.path, username=self.username, password=self.password, database=self.database_name, diff --git a/lib/ansible/plugins/doc_fragments/influxdb.py b/lib/ansible/plugins/doc_fragments/influxdb.py index 0489ff7ae6c..2bee3007f62 100644 --- a/lib/ansible/plugins/doc_fragments/influxdb.py +++ b/lib/ansible/plugins/doc_fragments/influxdb.py @@ -34,6 +34,11 @@ options: - The port on which InfluxDB server is listening type: int default: 8086 + path: + description: + - The path on which InfluxDB server is accessible + type: str + version_added: "2.10" validate_certs: description: - If set to C(no), the SSL certificates will not be validated.