Skip to content

Commit

Permalink
Fix various sanity errors in plugins (#881) (#893)
Browse files Browse the repository at this point in the history
* Fix deprecation of callables.

* Fix various sanity errors.

* Revert callback_type -> type transform.

* Fix stat_result times: these are float according to https://github.com/python/typeshed/blob/master/stdlib/3/os/__init__.pyi

* Apply suggestions from code review

Co-authored-by: Andrew Klychkov <[email protected]>

Co-authored-by: Andrew Klychkov <[email protected]>
(cherry picked from commit 7cf4728)

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
patchback[bot] and felixfontein authored Sep 17, 2020
1 parent 1dfd6e3 commit c802de8
Show file tree
Hide file tree
Showing 28 changed files with 88 additions and 27 deletions.
13 changes: 13 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,16 @@ plugin_routing:
removal_version: 2.0.0
warning_text: The mysql module_utils has been moved to the community.mysql collection.
redirect: community.mysql.mysql
callback:
actionable:
deprecation:
removal_version: 2.0.0
warning_text: see plugin documentation for details
full_skip:
deprecation:
removal_version: 2.0.0
warning_text: see plugin documentation for details
stderr:
deprecation:
removal_version: 2.0.0
warning_text: see plugin documentation for details
6 changes: 3 additions & 3 deletions plugins/become/pfexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
become_user:
description:
- User you 'become' to execute the task
- This plugin ignores this setting as pfexec uses it's own ``exec_attr`` to figure this out,
- This plugin ignores this setting as pfexec uses it's own C(exec_attr) to figure this out,
but it is supplied here for Ansible to make decisions needed for the task execution, like file permissions.
default: root
ini:
Expand Down Expand Up @@ -80,8 +80,8 @@
- name: ansible_pfexec_wrap_execution
env:
- name: ANSIBLE_PFEXEC_WRAP_EXECUTION
note:
- This plugin ignores ``become_user`` as pfexec uses it's own ``exec_attr`` to figure this out.
notes:
- This plugin ignores I(become_user) as pfexec uses it's own C(exec_attr) to figure this out.
'''

from ansible.plugins.become import BecomeBase
Expand Down
11 changes: 6 additions & 5 deletions plugins/callback/counter_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import constants as C
from ansible.plugins.callback import CallbackBase
from ansible.utils.color import colorize, hostcolor
from ansible.template import Templar
from ansible.playbook.task_include import TaskInclude

DOCUMENTATION = '''
callback: counter_enabled
Expand All @@ -26,6 +21,12 @@
- set as stdout callback in ansible.cfg (stdout_callback = counter_enabled)
'''

from ansible import constants as C
from ansible.plugins.callback import CallbackBase
from ansible.utils.color import colorize, hostcolor
from ansible.template import Templar
from ansible.playbook.task_include import TaskInclude


class CallbackModule(CallbackBase):

Expand Down
2 changes: 1 addition & 1 deletion plugins/callback/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
ini:
- section: callback_mail
key: bcc
note:
notes:
- "TODO: expand configuration options now that plugins can leverage Ansible's configuration"
'''

Expand Down
4 changes: 2 additions & 2 deletions plugins/inventory/gitlab_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
DOCUMENTATION = '''
name: gitlab_runners
plugin_type: inventory
authors:
- Stefan Heitmüller ([email protected])
author:
- Stefan Heitmüller (@morph027) <[email protected]>
short_description: Ansible dynamic inventory plugin for GitLab runners.
requirements:
- python >= 2.7
Expand Down
4 changes: 3 additions & 1 deletion plugins/lookup/chef_databag.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
RETURN = """
_raw:
description:
- The value from the databag
- The value from the databag.
type: list
elements: dict
"""

from ansible.errors import AnsibleError
Expand Down
1 change: 1 addition & 0 deletions plugins/lookup/consul_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
_raw:
description:
- Value(s) stored in consul.
type: dict
"""

import os
Expand Down
3 changes: 2 additions & 1 deletion plugins/lookup/credstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
RETURN = """
_raw:
description:
- value(s) stored in Credstash
- Value(s) stored in Credstash.
type: str
"""

import os
Expand Down
4 changes: 2 additions & 2 deletions plugins/lookup/cyberarkpassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
default: 'password'
_extra:
description: for extra_params values please check parameters for clipasswordsdk in CyberArk's "Credential Provider and ASCP Implementation Guide"
note:
- For Ansible on windows, please change the -parameters (-p, -d, and -o) to /parameters (/p, /d, and /o) and change the location of CLIPasswordSDK.exe
notes:
- For Ansible on Windows, please change the -parameters (-p, -d, and -o) to /parameters (/p, /d, and /o) and change the location of CLIPasswordSDK.exe.
'''

EXAMPLES = """
Expand Down
4 changes: 3 additions & 1 deletion plugins/lookup/dig.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
RETURN = """
_list:
description:
- list of composed strings or dictionaries with key and value
- List of composed strings or dictionaries with key and value
If a dictionary, fields shows the keys returned depending on query type
type: list
elements: raw
contains:
ALL:
description:
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/dsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
description:
- One or more JSON responses to C(GET /secrets/{path}).
- See U(https://dsv.thycotic.com/api/index.html#operation/getSecret).
type: list
elements: dict
"""

EXAMPLES = r"""
Expand Down
1 change: 1 addition & 0 deletions plugins/lookup/etcd3.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
seealso:
- module: community.general.etcd3
- ref: etcd_lookup
description: The etcd v2 lookup.
requirements:
- "etcd3 >= 0.10"
Expand Down
28 changes: 23 additions & 5 deletions plugins/lookup/filetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,60 @@

RETURN = r"""
_raw:
description: list of dictionaries with file information
description: List of dictionaries with file information.
type: list
elements: dict
contains:
src:
description:
- full path to file.
- not returned when C(item.state) is set to C(directory).
- Full path to file.
- Not returned when I(item.state) is set to C(directory).
type: path
root:
description: allows filtering by original location.
description: Allows filtering by original location.
type: path
path:
description: contains the relative path to root.
description: Contains the relative path to root.
type: path
mode:
description: The permissions the resulting file or directory.
type: str
state:
description: TODO
type: str
owner:
description: Name of the user that owns the file/directory.
type: raw
group:
description: Name of the group that owns the file/directory.
type: raw
seuser:
description: The user part of the SELinux file context.
type: raw
serole:
description: The role part of the SELinux file context.
type: raw
setype:
description: The type part of the SELinux file context.
type: raw
selevel:
description: The level part of the SELinux file context.
type: raw
uid:
description: Owner ID of the file/directory.
type: int
gid:
description: Group ID of the file/directory.
type: int
size:
description: Size of the target.
type: int
mtime:
description: Time of last modification.
type: float
ctime:
description: Time of last metadata update or creation (depends on OS).
type: float
"""
import os
import pwd
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/gcp_storage_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
_raw:
description:
- base64 encoded file content
type: list
elements: str
'''

import base64
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/hashi_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
_raw:
description:
- secrets(s) requested
type: list
elements: dict
"""

import os
Expand Down
5 changes: 3 additions & 2 deletions plugins/lookup/hiera.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
description:
- The list of keys to lookup on the Puppetmaster
type: list
element_type: string
elements: string
required: True
_bin_file:
description:
Expand Down Expand Up @@ -55,7 +55,8 @@
_raw:
description:
- a value associated with input key
type: strings
type: list
elements: str
"""

import os
Expand Down
4 changes: 3 additions & 1 deletion plugins/lookup/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

RETURN = """
_raw:
description: secrets stored
description: Secrets stored.
type: list
elements: str
"""

HAS_KEYRING = True
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/lastpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
RETURN = """
_raw:
description: secrets stored
type: list
elements: str
"""

from subprocess import Popen, PIPE
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/lmdb_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
RETURN = """
_raw:
description: value(s) stored in LMDB
type: list
elements: raw
"""


Expand Down
1 change: 0 additions & 1 deletion plugins/lookup/nios.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
obj_type:
description:
- The object type specified in the terms argument
returned: always
type: complex
contains:
obj_field:
Expand Down
1 change: 0 additions & 1 deletion plugins/lookup/nios_next_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
_list:
description:
- The list of next IP addresses available
returned: always
type: list
"""

Expand Down
1 change: 0 additions & 1 deletion plugins/lookup/nios_next_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
_list:
description:
- The list of next network addresses available
returned: always
type: list
"""

Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/onepassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
RETURN = """
_raw:
description: field data requested
type: list
elements: str
"""

import errno
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/onepassword_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
RETURN = """
_raw:
description: field data requested
type: list
elements: dict
"""

import json
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/passwordstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
_raw:
description:
- a password
type: list
elements: str
"""

import os
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
RETURN = """
_raw:
description: value(s) stored in Redis
type: list
elements: str
"""

import os
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/shelvefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
RETURN = """
_list:
description: value(s) of key(s) in shelve file(s)
type: list
elements: str
"""
import shelve

Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/tss.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
description:
- The JSON responses to C(GET /secrets/{id}).
- See U(https://updates.thycotic.net/secretserver/restapiguide/TokenAuth/#operation--secrets--id--get).
type: list
elements: dict
"""

EXAMPLES = r"""
Expand Down

0 comments on commit c802de8

Please sign in to comment.