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
pull/61697/head
Christian Fetzer 5 years ago committed by René Moser
parent 9ccef9e819
commit 7197c41fff

@ -36,6 +36,7 @@ class InfluxDb():
self.check_lib() self.check_lib()
self.hostname = self.params['hostname'] self.hostname = self.params['hostname']
self.port = self.params['port'] self.port = self.params['port']
self.path = self.params['path']
self.username = self.params['username'] self.username = self.params['username']
self.password = self.params['password'] self.password = self.params['password']
self.database_name = self.params.get('database_name') self.database_name = self.params.get('database_name')
@ -52,6 +53,7 @@ class InfluxDb():
return dict( return dict(
hostname=dict(type='str', default='localhost'), hostname=dict(type='str', default='localhost'),
port=dict(type='int', default=8086), port=dict(type='int', default=8086),
path=dict(type='str', default=''),
username=dict(type='str', default='root', aliases=['login_username']), username=dict(type='str', default='root', aliases=['login_username']),
password=dict(type='str', default='root', no_log=True, aliases=['login_password']), password=dict(type='str', default='root', no_log=True, aliases=['login_password']),
ssl=dict(type='bool', default=False), ssl=dict(type='bool', default=False),
@ -67,6 +69,7 @@ class InfluxDb():
args = dict( args = dict(
host=self.hostname, host=self.hostname,
port=self.port, port=self.port,
path=self.path,
username=self.username, username=self.username,
password=self.password, password=self.password,
database=self.database_name, database=self.database_name,

@ -34,6 +34,11 @@ options:
- The port on which InfluxDB server is listening - The port on which InfluxDB server is listening
type: int type: int
default: 8086 default: 8086
path:
description:
- The path on which InfluxDB server is accessible
type: str
version_added: "2.10"
validate_certs: validate_certs:
description: description:
- If set to C(no), the SSL certificates will not be validated. - If set to C(no), the SSL certificates will not be validated.

Loading…
Cancel
Save