From 5bcc9cd1c327a0b19d18ad5f9b78b01ff4e0894d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Wed, 13 Dec 2017 12:41:57 +0100 Subject: [PATCH] influxdb: fix missing arg specs (#33859) * influxdb: fix missing arg specs * influxdb: doc: move database_name spec to doc fragments * influxdb: cleanup unused import --- lib/ansible/module_utils/influxdb.py | 9 +++++++-- .../database/influxdb/influxdb_database.py | 20 ++++++------------- .../influxdb/influxdb_retention_policy.py | 17 ++++++---------- .../utils/module_docs_fragments/influxdb.py | 4 ++++ 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/lib/ansible/module_utils/influxdb.py b/lib/ansible/module_utils/influxdb.py index c423a8110d..aa653ede14 100644 --- a/lib/ansible/module_utils/influxdb.py +++ b/lib/ansible/module_utils/influxdb.py @@ -2,6 +2,9 @@ # Copyright: (c) 2017, Ansible Project # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) +from __future__ import absolute_import, division, print_function +__metaclass__ = type + try: import requests.exceptions HAS_REQUESTS = True @@ -16,7 +19,7 @@ except ImportError: HAS_INFLUXDB = False -class InfluxDb(object): +class InfluxDb(): def __init__(self, module): self.module = module self.params = self.module.params @@ -44,9 +47,11 @@ class InfluxDb(object): database_name=dict(required=True, type='str'), ssl=dict(default=False, type='bool'), validate_certs=dict(default=True, type='bool'), - timeout=dict(default=None, type='int'), + timeout=dict(type='int'), retries=dict(default=3, type='int'), proxies=dict(default={}, type='dict'), + use_udp=dict(default=False, type='bool'), + udp_port=dict(type=int) ) def connect_to_influxdb(self): diff --git a/lib/ansible/modules/database/influxdb/influxdb_database.py b/lib/ansible/modules/database/influxdb/influxdb_database.py index b108e9c235..6e14bd94b9 100644 --- a/lib/ansible/modules/database/influxdb/influxdb_database.py +++ b/lib/ansible/modules/database/influxdb/influxdb_database.py @@ -25,17 +25,12 @@ requirements: - "influxdb >= 0.9" - requests options: - database_name: - description: - - Name of the database that will be created/destroyed - required: true state: description: - - Determines if the database should be created or destroyed - choices: ['present', 'absent'] + - Determines if the database should be created or destroyed. + choices: [ present, absent ] default: present - required: false -extends_documentation_fragment: influxdb.documentation +extends_documentation_fragment: influxdb ''' EXAMPLES = ''' @@ -44,7 +39,6 @@ EXAMPLES = ''' influxdb_database: hostname: "{{influxdb_ip_address}}" database_name: "{{influxdb_database_name}}" - state: present - name: Destroy database influxdb_database: @@ -58,18 +52,16 @@ EXAMPLES = ''' username: "{{influxdb_username}}" password: "{{influxdb_password}}" database_name: "{{influxdb_database_name}}" - state: present - ssl: False - validate_certs: False + ssl: yes + validate_certs: yes ''' RETURN = ''' -#only defaults +# only defaults ''' try: import requests.exceptions - from influxdb import InfluxDBClient from influxdb import exceptions except ImportError: pass diff --git a/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py b/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py index c00ac62821..83bef25a61 100644 --- a/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py +++ b/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py @@ -25,10 +25,6 @@ requirements: - "influxdb >= 0.9" - requests options: - database_name: - description: - - Name of the database where retention policy will be created - required: true policy_name: description: - Name of the retention policy @@ -45,7 +41,7 @@ options: description: - Sets the retention policy as default retention policy required: true -extends_documentation_fragment: influxdb.documentation +extends_documentation_fragment: influxdb ''' EXAMPLES = ''' @@ -57,8 +53,8 @@ EXAMPLES = ''' policy_name: test duration: 1h replication: 1 - ssl: True - validate_certs: True + ssl: yes + validate_certs: yes - name: create 1 day retention policy influxdb_retention_policy: @@ -83,19 +79,18 @@ EXAMPLES = ''' policy_name: test duration: INF replication: 1 - ssl: False - validate_certs: False + ssl: no + validate_certs: no ''' RETURN = ''' -#only defaults +# only defaults ''' import re try: import requests.exceptions - from influxdb import InfluxDBClient from influxdb import exceptions except ImportError: pass diff --git a/lib/ansible/utils/module_docs_fragments/influxdb.py b/lib/ansible/utils/module_docs_fragments/influxdb.py index f600e5a5f3..1656322c26 100644 --- a/lib/ansible/utils/module_docs_fragments/influxdb.py +++ b/lib/ansible/utils/module_docs_fragments/influxdb.py @@ -23,6 +23,10 @@ options: description: - The port on which InfluxDB server is listening default: 8086 + database_name: + description: + - Name of the database. + required: true validate_certs: description: - If set to C(no), the SSL certificates will not be validated.