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

InfluxDB_database: Make the path argument conditional on the InfluxDB version (#1126)

Co-authored-by: Mathias Ettinger <mathias.ettinger@viveris.f>
This commit is contained in:
Mathias Ettinger 2020-11-06 09:12:00 +01:00 committed by GitHub
parent c85aa96177
commit ce0f327875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View file

@ -0,0 +1,4 @@
---
bugfixes:
- influxdb - fix usage of path for older version of
python-influxdb (https://github.com/ansible-collections/community.general/issues/997).

View file

@ -40,6 +40,7 @@ options:
path:
description:
- The path on which InfluxDB server is accessible
- Only available when using python-influxdb >= 5.1.0
type: str
version_added: '0.2.0'
validate_certs:
@ -60,6 +61,7 @@ options:
description:
- Number of retries client will try before aborting.
- C(0) indicates try until success.
- Only available when using python-influxdb >= 4.1.0
type: int
default: 3
use_udp:

View file

@ -9,6 +9,7 @@ __metaclass__ = type
import traceback
from ansible.module_utils.basic import missing_required_lib
from distutils.version import LooseVersion
REQUESTS_IMP_ERR = None
try:
@ -69,7 +70,6 @@ class InfluxDb():
args = dict(
host=self.hostname,
port=self.port,
path=self.path,
username=self.username,
password=self.password,
database=self.database_name,
@ -80,9 +80,13 @@ class InfluxDb():
udp_port=self.params['udp_port'],
proxies=self.params['proxies'],
)
influxdb_api_version = tuple(influxdb_version.split("."))
if influxdb_api_version >= ('4', '1', '0'):
influxdb_api_version = LooseVersion(influxdb_version)
if influxdb_api_version >= LooseVersion('4.1.0'):
# retries option is added in version 4.1.0
args.update(retries=self.params['retries'])
if influxdb_api_version >= LooseVersion('5.1.0'):
# path argument is added in version 5.1.0
args.update(path=self.path)
return InfluxDBClient(**args)

View file

@ -16,7 +16,7 @@ description:
author: "Kamil Szczygiel (@kamsz)"
requirements:
- "python >= 2.6"
- "influxdb >= 0.9 & <= 1.2.4"
- "influxdb >= 0.9"
- requests
options:
database_name: