From 27dfdb6a6a13e4e5117665d2c51c4474eb84888b Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 15 Feb 2019 09:32:45 +0100 Subject: [PATCH] doc_fragments: Clean up parameter types (database) (#52178) * module_utils: Clean up parameter types (database) This PR includes: - Parameter types added - Copyright format fixes - Short license statement - Description fixes (only for a few files, then I stopped :-)) * Fix validate-modules test ignores --- lib/ansible/plugins/doc_fragments/influxdb.py | 23 ++++++++--- lib/ansible/plugins/doc_fragments/mysql.py | 37 +++++++++--------- lib/ansible/plugins/doc_fragments/postgres.py | 38 +++++++++---------- lib/ansible/plugins/doc_fragments/proxysql.py | 11 +++++- test/sanity/validate-modules/ignore.txt | 4 -- 5 files changed, 61 insertions(+), 52 deletions(-) diff --git a/lib/ansible/plugins/doc_fragments/influxdb.py b/lib/ansible/plugins/doc_fragments/influxdb.py index ac4c2ed781..4c40414ac7 100644 --- a/lib/ansible/plugins/doc_fragments/influxdb.py +++ b/lib/ansible/plugins/doc_fragments/influxdb.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + # Copyright: (c) 2017, Ansible Project # Copyright: (c) 2017, Abhijeet Kasurde (akasurde@redhat.com) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -5,60 +7,71 @@ class ModuleDocFragment(object): # Parameters for influxdb modules - DOCUMENTATION = ''' + DOCUMENTATION = r''' options: hostname: description: - The hostname or IP address on which InfluxDB server is listening. - - Since version 2.5, defaulted to localhost. + - Since Ansible 2.5, defaulted to localhost. + type: str default: localhost username: description: - Username that will be used to authenticate against InfluxDB server. - - Alias C(login_username) added in version 2.5. + - Alias C(login_username) added in Ansible 2.5. + type: str default: root aliases: [ login_username ] password: description: - Password that will be used to authenticate against InfluxDB server. - - Alias C(login_password) added in version 2.5. + - Alias C(login_password) added in Ansible 2.5. + type: str default: root aliases: [ login_password ] port: description: - The port on which InfluxDB server is listening + type: int default: 8086 validate_certs: description: - If set to C(no), the SSL certificates will not be validated. - This should only set to C(no) used on personally controlled sites using self-signed certificates. - default: true + type: bool + default: yes version_added: "2.5" ssl: description: - Use https instead of http to connect to InfluxDB server. + type: bool version_added: "2.5" timeout: description: - Number of seconds Requests will wait for client to establish a connection. + type: int version_added: "2.5" retries: description: - Number of retries client will try before aborting. - C(0) indicates try until success. + type: int default: 3 version_added: "2.5" use_udp: description: - Use UDP to connect to InfluxDB server. + type: bool version_added: "2.5" udp_port: description: - UDP port to connect to InfluxDB server. + type: int default: 4444 version_added: "2.5" proxies: description: - HTTP(S) proxy to use for Requests to connect to InfluxDB server. + type: str version_added: "2.5" ''' diff --git a/lib/ansible/plugins/doc_fragments/mysql.py b/lib/ansible/plugins/doc_fragments/mysql.py index 58a9deac95..ffc01825fd 100644 --- a/lib/ansible/plugins/doc_fragments/mysql.py +++ b/lib/ansible/plugins/doc_fragments/mysql.py @@ -1,67 +1,64 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2015 Jonathan Mainguy -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . + +# Copyright: (c) 2015, Jonathan Mainguy +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) class ModuleDocFragment(object): # Standard mysql documentation fragment - DOCUMENTATION = ''' + DOCUMENTATION = r''' options: login_user: description: - The username used to authenticate with. + type: str login_password: description: - The password used to authenticate with. + type: str login_host: description: - Host running the database. + type: str default: localhost login_port: description: - Port of the MySQL server. Requires I(login_host) be defined as other than localhost if login_port is used. + type: str default: 3306 login_unix_socket: description: - The path to a Unix domain socket for local connections. + type: str connect_timeout: description: - The connection timeout when connecting to the MySQL server. + type: int default: 30 version_added: "2.1" config_file: description: - Specify a config file from which user and password are to be read. + type: path default: '~/.my.cnf' version_added: "2.0" ssl_ca: - version_added: "2.0" description: - The path to a Certificate Authority (CA) certificate. This option, if used, must specify the same certificate as used by the server. - ssl_cert: + type: path version_added: "2.0" + ssl_cert: description: - The path to a client public key certificate. - ssl_key: + type: path version_added: "2.0" + ssl_key: description: - The path to the client private key. + type: path + version_added: "2.0" requirements: - PyMySQL (Python 2.7 and Python 3.X), or - MySQLdb (Python 2.x) diff --git a/lib/ansible/plugins/doc_fragments/postgres.py b/lib/ansible/plugins/doc_fragments/postgres.py index 5068ea064f..a579e30dec 100644 --- a/lib/ansible/plugins/doc_fragments/postgres.py +++ b/lib/ansible/plugins/doc_fragments/postgres.py @@ -1,52 +1,48 @@ -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) class ModuleDocFragment(object): # Postgres documentation fragment - DOCUMENTATION = """ + DOCUMENTATION = r''' options: login_user: description: - - The username used to authenticate with + - The username used to authenticate with. + type: str default: postgres login_password: description: - - The password used to authenticate with + - The password used to authenticate with. + type: str login_host: description: - - Host running the database + - Host running the database. + type: str login_unix_socket: description: - - Path to a Unix domain socket for local connections + - Path to a Unix domain socket for local connections. + type: path port: description: - Database port to connect to. + type: int default: 5432 ssl_mode: description: - Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. - See https://www.postgresql.org/docs/current/static/libpq-ssl.html for more information on the modes. - Default of C(prefer) matches libpq default. + type: str default: prefer - choices: [disable, allow, prefer, require, verify-ca, verify-full] + choices: [ allow, disable, prefer, require, verify-ca, verify-full ] version_added: '2.3' ssl_rootcert: description: - Specifies the name of a file containing SSL certificate authority (CA) certificate(s). - If the file exists, the server's certificate will be verified to be signed by one of these authorities. + type: path version_added: '2.3' notes: - The default authentication assumes that you are either logging in as or sudo'ing to the C(postgres) account on the host. @@ -56,4 +52,4 @@ notes: and C(python-psycopg2) packages on the remote host before using this module. - The ssl_rootcert parameter requires at least Postgres version 8.4 and I(psycopg2) version 2.4.3. requirements: [ psycopg2 ] -""" +''' diff --git a/lib/ansible/plugins/doc_fragments/proxysql.py b/lib/ansible/plugins/doc_fragments/proxysql.py index ad65911cf9..cd67e8b160 100644 --- a/lib/ansible/plugins/doc_fragments/proxysql.py +++ b/lib/ansible/plugins/doc_fragments/proxysql.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt @@ -5,26 +7,31 @@ class ModuleDocFragment(object): # Documentation fragment for ProxySQL connectivity - CONNECTIVITY = ''' + CONNECTIVITY = r''' options: login_user: description: - The username used to authenticate to ProxySQL admin interface. + type: str login_password: description: - The password used to authenticate to ProxySQL admin interface. + type: str login_host: description: - The host used to connect to ProxySQL admin interface. + type: str default: '127.0.0.1' login_port: description: - The port used to connect to ProxySQL admin interface. + type: int default: 6032 config_file: description: - Specify a config file from which I(login_user) and I(login_password) are to be read. + type: path default: '' requirements: - PyMySQL (Python 2.7 and Python 3.X), or @@ -32,7 +39,7 @@ requirements: ''' # Documentation fragment for managing ProxySQL configuration - MANAGING_CONFIG = ''' + MANAGING_CONFIG = r''' options: save_to_disk: description: diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index 26e36e460c..6d7b4cbcf7 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -363,15 +363,11 @@ lib/ansible/modules/commands/command.py E325 lib/ansible/modules/crypto/openssl_certificate.py E325 lib/ansible/modules/crypto/openssl_csr.py E325 lib/ansible/modules/database/influxdb/influxdb_database.py E324 -lib/ansible/modules/database/influxdb/influxdb_database.py E325 lib/ansible/modules/database/influxdb/influxdb_query.py E324 -lib/ansible/modules/database/influxdb/influxdb_query.py E325 lib/ansible/modules/database/influxdb/influxdb_retention_policy.py E324 lib/ansible/modules/database/influxdb/influxdb_retention_policy.py E325 lib/ansible/modules/database/influxdb/influxdb_user.py E324 -lib/ansible/modules/database/influxdb/influxdb_user.py E325 lib/ansible/modules/database/influxdb/influxdb_write.py E324 -lib/ansible/modules/database/influxdb/influxdb_write.py E325 lib/ansible/modules/database/misc/riak.py E324 lib/ansible/modules/database/mongodb/mongodb_parameter.py E317 lib/ansible/modules/database/mongodb/mongodb_parameter.py E323