From 69744aa0a7fdafb6a0b988f66ec835dad39fefbc Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 24 Oct 2020 13:03:18 +0200 Subject: [PATCH] [2.10] Fix various sanity errors in plugins (#72168) * Fix various sanity errors in plugins (#71736) * Fix various sanity errors in plugins. * Revert callback_type -> type transform. * Undo paramiko_ssh 'connection' change, since this discrepancy is hardcoded in the plugin loader. * Standardize on name and type (for callbacks). * Fix existing author entries. * Add 'Unknown (!UNKNOWN)' as author when author is missing. * These are actually parsed as integers in the code. * Revert "Add 'Unknown (!UNKNOWN)' as author when author is missing." This reverts commit 29d1438aca4cb1988ac81c9f6cb3c4e0403b5fae. (cherry picked from commit aff78f4cbc9a1afe70ca447e17e4c99582ad16b3) * Undo potentially disrupting normalizations. * Add changelog fragment for #71736. (#72323) (cherry picked from commit 0b2b82c0b6eb6466c18cd6feea2222ec756b8f48) --- changelogs/fragments/url-lookup-ini.yml | 2 ++ lib/ansible/plugins/inventory/auto.py | 3 ++- lib/ansible/plugins/inventory/toml.py | 2 +- lib/ansible/plugins/lookup/config.py | 3 ++- lib/ansible/plugins/lookup/csvfile.py | 2 ++ lib/ansible/plugins/lookup/file.py | 4 +++- lib/ansible/plugins/lookup/fileglob.py | 4 +++- lib/ansible/plugins/lookup/first_found.py | 4 +++- lib/ansible/plugins/lookup/indexed_items.py | 3 ++- lib/ansible/plugins/lookup/ini.py | 4 +++- .../plugins/lookup/inventory_hostnames.py | 4 ++-- lib/ansible/plugins/lookup/items.py | 2 +- lib/ansible/plugins/lookup/lines.py | 4 +++- lib/ansible/plugins/lookup/list.py | 4 +++- lib/ansible/plugins/lookup/password.py | 8 +++++--- lib/ansible/plugins/lookup/pipe.py | 4 +++- lib/ansible/plugins/lookup/random_choice.py | 3 ++- lib/ansible/plugins/lookup/sequence.py | 11 +++++----- lib/ansible/plugins/lookup/subelements.py | 2 +- lib/ansible/plugins/lookup/template.py | 4 +++- lib/ansible/plugins/lookup/together.py | 4 +++- lib/ansible/plugins/lookup/unvault.py | 4 +++- lib/ansible/plugins/lookup/url.py | 20 ++++++++++--------- lib/ansible/plugins/lookup/varnames.py | 2 +- lib/ansible/plugins/lookup/vars.py | 4 +++- lib/ansible/plugins/strategy/debug.py | 2 +- 26 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 changelogs/fragments/url-lookup-ini.yml diff --git a/changelogs/fragments/url-lookup-ini.yml b/changelogs/fragments/url-lookup-ini.yml new file mode 100644 index 00000000000..0d8b68349bb --- /dev/null +++ b/changelogs/fragments/url-lookup-ini.yml @@ -0,0 +1,2 @@ +bugfixes: +- "url lookup - make sure that options supplied in ansible.cfg are actually used (https://github.com/ansible/ansible/pull/71736)." diff --git a/lib/ansible/plugins/inventory/auto.py b/lib/ansible/plugins/inventory/auto.py index cf4ed0c347c..bbb52bae5a8 100644 --- a/lib/ansible/plugins/inventory/auto.py +++ b/lib/ansible/plugins/inventory/auto.py @@ -8,7 +8,8 @@ DOCUMENTATION = ''' name: auto plugin_type: inventory author: - - Matt Davis <@nitzmahone> + - Matt Davis (@nitzmahone) + version_added: "2.5" short_description: Loads and executes an inventory plugin specified in a YAML config description: - By whitelisting C(auto) inventory plugin, any YAML inventory config file with a diff --git a/lib/ansible/plugins/inventory/toml.py b/lib/ansible/plugins/inventory/toml.py index 8a3e7f7a62c..26ad600ae8e 100644 --- a/lib/ansible/plugins/inventory/toml.py +++ b/lib/ansible/plugins/inventory/toml.py @@ -159,7 +159,7 @@ class InventoryModule(BaseFileInventoryPlugin): NAME = 'toml' def _parse_group(self, group, group_data): - if not isinstance(group_data, (MutableMapping, type(None))): + if group_data is not None and not isinstance(group_data, MutableMapping): self.display.warning("Skipping '%s' as this is not a valid group definition" % group) return diff --git a/lib/ansible/plugins/lookup/config.py b/lib/ansible/plugins/lookup/config.py index 20ec25427fc..ceea80c3d8a 100644 --- a/lib/ansible/plugins/lookup/config.py +++ b/lib/ansible/plugins/lookup/config.py @@ -5,7 +5,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: config - author: Ansible Core + author: Ansible Core Team version_added: "2.5" short_description: Lookup current Ansible configuration values description: @@ -53,6 +53,7 @@ RETURN = """ _raw: description: - value(s) of the key(s) in the config + type: raw """ from ansible import constants as C diff --git a/lib/ansible/plugins/lookup/csvfile.py b/lib/ansible/plugins/lookup/csvfile.py index 03d9e6e9f51..af76ed1b085 100644 --- a/lib/ansible/plugins/lookup/csvfile.py +++ b/lib/ansible/plugins/lookup/csvfile.py @@ -56,6 +56,8 @@ RETURN = """ _raw: description: - value(s) stored in file column + type: list + elements: str """ import codecs diff --git a/lib/ansible/plugins/lookup/file.py b/lib/ansible/plugins/lookup/file.py index 3ce41559bd6..7b426a6c52f 100644 --- a/lib/ansible/plugins/lookup/file.py +++ b/lib/ansible/plugins/lookup/file.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: file - author: Daniel Hokka Zakrisson + author: Daniel Hokka Zakrisson (!UNKNOWN) version_added: "0.9" short_description: read file contents description: @@ -45,6 +45,8 @@ RETURN = """ _raw: description: - content of file(s) + type: list + elements: str """ from ansible.errors import AnsibleError, AnsibleParserError diff --git a/lib/ansible/plugins/lookup/fileglob.py b/lib/ansible/plugins/lookup/fileglob.py index 05628defd8e..aa5d7d34d8a 100644 --- a/lib/ansible/plugins/lookup/fileglob.py +++ b/lib/ansible/plugins/lookup/fileglob.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: fileglob - author: Michael DeHaan + author: Michael DeHaan version_added: "1.4" short_description: list files matching a pattern description: @@ -41,6 +41,8 @@ RETURN = """ _list: description: - list of files + type: list + elements: path """ import os diff --git a/lib/ansible/plugins/lookup/first_found.py b/lib/ansible/plugins/lookup/first_found.py index 1668f51f2b7..54bc6849cac 100644 --- a/lib/ansible/plugins/lookup/first_found.py +++ b/lib/ansible/plugins/lookup/first_found.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: first_found - author: Seth Vidal + author: Seth Vidal (!UNKNOWN) version_added: historical short_description: return first file found from list description: @@ -99,6 +99,8 @@ RETURN = """ _raw: description: - path to file found + type: list + elements: path """ import os diff --git a/lib/ansible/plugins/lookup/indexed_items.py b/lib/ansible/plugins/lookup/indexed_items.py index cd25ba15fa6..967e3999bf8 100644 --- a/lib/ansible/plugins/lookup/indexed_items.py +++ b/lib/ansible/plugins/lookup/indexed_items.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: indexed_items - author: Michael DeHaan + author: Michael DeHaan version_added: "1.3" short_description: rewrites lists to return 'indexed items' description: @@ -31,6 +31,7 @@ RETURN = """ description: - list with each item.0 giving you the position and item.1 the value type: list + elements: list """ from ansible.errors import AnsibleError diff --git a/lib/ansible/plugins/lookup/ini.py b/lib/ansible/plugins/lookup/ini.py index f886a8d9b1b..b53468b363a 100644 --- a/lib/ansible/plugins/lookup/ini.py +++ b/lib/ansible/plugins/lookup/ini.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: ini - author: Yannig Perre + author: Yannig Perre (!UNKNOWN) version_added: "2.0" short_description: read data from a ini file description: @@ -56,6 +56,8 @@ RETURN = """ _raw: description: - value(s) of the key(s) in the ini file + type: list + elements: str """ import os import re diff --git a/lib/ansible/plugins/lookup/inventory_hostnames.py b/lib/ansible/plugins/lookup/inventory_hostnames.py index 001abdbab39..a9f521cc004 100644 --- a/lib/ansible/plugins/lookup/inventory_hostnames.py +++ b/lib/ansible/plugins/lookup/inventory_hostnames.py @@ -9,8 +9,8 @@ __metaclass__ = type DOCUMENTATION = """ lookup: inventory_hostnames author: - - Michael DeHaan - - Steven Dossett + - Michael DeHaan + - Steven Dossett (!UNKNOWN) version_added: "1.3" short_description: list of inventory hosts matching a host pattern description: diff --git a/lib/ansible/plugins/lookup/items.py b/lib/ansible/plugins/lookup/items.py index 6a4299e70b7..3410e74624b 100644 --- a/lib/ansible/plugins/lookup/items.py +++ b/lib/ansible/plugins/lookup/items.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: items - author: Michael DeHaan + author: Michael DeHaan version_added: historical short_description: list of items description: diff --git a/lib/ansible/plugins/lookup/lines.py b/lib/ansible/plugins/lookup/lines.py index 2707d6cbf3b..b7fb875b307 100644 --- a/lib/ansible/plugins/lookup/lines.py +++ b/lib/ansible/plugins/lookup/lines.py @@ -7,7 +7,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: lines - author: Daniel Hokka Zakrisson + author: Daniel Hokka Zakrisson (!UNKNOWN) version_added: "0.9" short_description: read lines from command description: @@ -37,6 +37,8 @@ RETURN = """ _list: description: - lines of stdout from command + type: list + elements: str """ import subprocess diff --git a/lib/ansible/plugins/lookup/list.py b/lib/ansible/plugins/lookup/list.py index 60ea53151ac..e57cdd64b99 100644 --- a/lib/ansible/plugins/lookup/list.py +++ b/lib/ansible/plugins/lookup/list.py @@ -8,7 +8,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: list - author: Ansible core team + author: Ansible Core Team version_added: "2.0" short_description: simply returns what it is given. description: @@ -27,6 +27,8 @@ EXAMPLES = """ RETURN = """ _list: description: basically the same as you fed in + type: list + elements: raw """ from ansible.module_utils.common._collections_compat import Sequence diff --git a/lib/ansible/plugins/lookup/password.py b/lib/ansible/plugins/lookup/password.py index 21ab78ec05a..81b5d5004ff 100644 --- a/lib/ansible/plugins/lookup/password.py +++ b/lib/ansible/plugins/lookup/password.py @@ -10,9 +10,9 @@ DOCUMENTATION = """ lookup: password version_added: "1.1" author: - - Daniel Hokka Zakrisson - - Javier Candeira - - Maykel Moya + - Daniel Hokka Zakrisson (!UNKNOWN) + - Javier Candeira (!UNKNOWN) + - Maykel Moya (!UNKNOWN) short_description: retrieve or generate a random password, stored in a file description: - Generates a random plaintext password and stores it in a file at a given filepath. @@ -90,6 +90,8 @@ RETURN = """ _raw: description: - a password + type: list + elements: str """ import os diff --git a/lib/ansible/plugins/lookup/pipe.py b/lib/ansible/plugins/lookup/pipe.py index 94ad0104343..a640a0cff6f 100644 --- a/lib/ansible/plugins/lookup/pipe.py +++ b/lib/ansible/plugins/lookup/pipe.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = r""" lookup: pipe - author: Daniel Hokka Zakrisson + author: Daniel Hokka Zakrisson (!UNKNOWN) version_added: "0.9" short_description: read output from a command description: @@ -40,6 +40,8 @@ RETURN = r""" _string: description: - stdout from command + type: list + elements: str """ import subprocess diff --git a/lib/ansible/plugins/lookup/random_choice.py b/lib/ansible/plugins/lookup/random_choice.py index 05b4080d489..348a41d6175 100644 --- a/lib/ansible/plugins/lookup/random_choice.py +++ b/lib/ansible/plugins/lookup/random_choice.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: random_choice - author: Michael DeHaan + author: Michael DeHaan version_added: "1.1" short_description: return random element from list description: @@ -30,6 +30,7 @@ RETURN = """ _raw: description: - random item + type: raw """ import random diff --git a/lib/ansible/plugins/lookup/sequence.py b/lib/ansible/plugins/lookup/sequence.py index 12625c0505a..ddf656762ea 100644 --- a/lib/ansible/plugins/lookup/sequence.py +++ b/lib/ansible/plugins/lookup/sequence.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: sequence - author: Jayson Vantuyl + author: Jayson Vantuyl (!UNKNOWN) version_added: "1.0" short_description: generate a list based on a number sequence description: @@ -21,18 +21,18 @@ DOCUMENTATION = """ start: description: number at which to start the sequence default: 0 - type: number + type: integer end: description: number at which to end the sequence, dont use this with count - type: number + type: integer default: 0 count: description: number of elements in the sequence, this is not to be used with end - type: number + type: integer default: 0 stride: description: increments between sequence numbers, the default is 1 unless the end is less than the start, then it is -1. - type: number + type: integer format: description: return a string with the generated number formatted in """ @@ -74,6 +74,7 @@ RETURN = """ description: - A list containing generated sequence of items type: list + elements: str """ from re import compile as re_compile, IGNORECASE diff --git a/lib/ansible/plugins/lookup/subelements.py b/lib/ansible/plugins/lookup/subelements.py index a948f0204ef..b05856bf471 100644 --- a/lib/ansible/plugins/lookup/subelements.py +++ b/lib/ansible/plugins/lookup/subelements.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: subelements - author: Serge van Ginderachter + author: Serge van Ginderachter (!UNKNOWN) version_added: "1.4" short_description: traverse nested key from a list of dictionaries description: diff --git a/lib/ansible/plugins/lookup/template.py b/lib/ansible/plugins/lookup/template.py index 666fe91ecd1..dd4a274916f 100644 --- a/lib/ansible/plugins/lookup/template.py +++ b/lib/ansible/plugins/lookup/template.py @@ -7,7 +7,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: template - author: Michael DeHaan + author: Michael DeHaan version_added: "0.9" short_description: retrieve contents of file after templating with Jinja2 description: @@ -43,6 +43,8 @@ EXAMPLES = """ RETURN = """ _raw: description: file(s) content after templating + type: list + elements: raw """ from copy import deepcopy diff --git a/lib/ansible/plugins/lookup/together.py b/lib/ansible/plugins/lookup/together.py index 1234ac6204f..a20e205aa20 100644 --- a/lib/ansible/plugins/lookup/together.py +++ b/lib/ansible/plugins/lookup/together.py @@ -6,7 +6,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: together - author: Bradley Young + author: Bradley Young (!UNKNOWN) version_added: '1.3' short_description: merges lists into synchronized list description: @@ -32,6 +32,8 @@ EXAMPLES = """ RETURN = """ _list: description: synchronized list + type: list + elements: list """ from ansible.errors import AnsibleError from ansible.module_utils.six.moves import zip_longest diff --git a/lib/ansible/plugins/lookup/unvault.py b/lib/ansible/plugins/lookup/unvault.py index 820da6c2d80..234a52a7917 100644 --- a/lib/ansible/plugins/lookup/unvault.py +++ b/lib/ansible/plugins/lookup/unvault.py @@ -5,7 +5,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: unvault - author: ansible core team + author: Ansible Core Team version_added: "2.10" short_description: read vaulted file(s) contents description: @@ -26,6 +26,8 @@ RETURN = """ _raw: description: - content of file(s) as bytes + type: list + elements: raw """ from ansible.errors import AnsibleParserError diff --git a/lib/ansible/plugins/lookup/url.py b/lib/ansible/plugins/lookup/url.py index 3896c8b57cb..1c24ebf8e5f 100644 --- a/lib/ansible/plugins/lookup/url.py +++ b/lib/ansible/plugins/lookup/url.py @@ -50,7 +50,7 @@ options: - name: ANSIBLE_LOOKUP_URL_FORCE ini: - section: url_lookup - - key: force + key: force timeout: description: How long to wait for the server to send data before giving up type: float @@ -62,7 +62,7 @@ options: - name: ANSIBLE_LOOKUP_URL_TIMEOUT ini: - section: url_lookup - - key: timeout + key: timeout http_agent: description: User-Agent to use in the request type: string @@ -73,7 +73,7 @@ options: - name: ANSIBLE_LOOKUP_URL_AGENT ini: - section: url_lookup - - key: agent + key: agent force_basic_auth: description: Force basic authentication type: boolean @@ -85,7 +85,7 @@ options: - name: ANSIBLE_LOOKUP_URL_AGENT ini: - section: url_lookup - - key: agent + key: agent follow_redirects: description: String of urllib2, all/yes, safe, none to determine how redirects are followed, see RedirectHandlerFactory for more information type: string @@ -97,7 +97,7 @@ options: - name: ANSIBLE_LOOKUP_URL_FOLLOW_REDIRECTS ini: - section: url_lookup - - key: follow_redirects + key: follow_redirects use_gssapi: description: Use GSSAPI handler of requests type: boolean @@ -109,7 +109,7 @@ options: - name: ANSIBLE_LOOKUP_URL_USE_GSSAPI ini: - section: url_lookup - - key: use_gssapi + key: use_gssapi unix_socket: description: String of file system path to unix socket file to use when establishing connection to the provided url type: string @@ -120,7 +120,7 @@ options: - name: ANSIBLE_LOOKUP_URL_UNIX_SOCKET ini: - section: url_lookup - - key: unix_socket + key: unix_socket ca_path: description: String of file system path to CA cert bundle to use type: string @@ -131,7 +131,7 @@ options: - name: ANSIBLE_LOOKUP_URL_CA_PATH ini: - section: url_lookup - - key: ca_path + key: ca_path unredirected_headers: description: A list of headers to not attach on a redirected request type: list @@ -142,7 +142,7 @@ options: - name: ANSIBLE_LOOKUP_URL_UNREDIR_HEADERS ini: - section: url_lookup - - key: unredirected_headers + key: unredirected_headers """ EXAMPLES = """ @@ -166,6 +166,8 @@ EXAMPLES = """ RETURN = """ _list: description: list of list of lines or content of url(s) + type: list + elements: str """ from ansible.errors import AnsibleError diff --git a/lib/ansible/plugins/lookup/varnames.py b/lib/ansible/plugins/lookup/varnames.py index c786903dd8f..32862951c68 100644 --- a/lib/ansible/plugins/lookup/varnames.py +++ b/lib/ansible/plugins/lookup/varnames.py @@ -5,7 +5,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: varnames - author: Ansible Core + author: Ansible Core Team version_added: "2.8" short_description: Lookup matching variable names description: diff --git a/lib/ansible/plugins/lookup/vars.py b/lib/ansible/plugins/lookup/vars.py index 5895b93f9fc..da3848ba70b 100644 --- a/lib/ansible/plugins/lookup/vars.py +++ b/lib/ansible/plugins/lookup/vars.py @@ -5,7 +5,7 @@ __metaclass__ = type DOCUMENTATION = """ lookup: vars - author: Ansible Core + author: Ansible Core Team version_added: "2.5" short_description: Lookup templated value of variables description: @@ -63,6 +63,8 @@ RETURN = """ _value: description: - value of the variables requested. + type: list + elements: raw """ from ansible.errors import AnsibleError, AnsibleUndefinedVariable diff --git a/lib/ansible/plugins/strategy/debug.py b/lib/ansible/plugins/strategy/debug.py index 5daea894b2e..1b23c7dfe69 100644 --- a/lib/ansible/plugins/strategy/debug.py +++ b/lib/ansible/plugins/strategy/debug.py @@ -21,7 +21,7 @@ DOCUMENTATION = ''' description: - Task execution is 'linear' but controlled by an interactive debug session. version_added: "2.1" - author: Kishin Yagami + author: Kishin Yagami (!UNKNOWN) ''' import cmd