diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2017-09-08 11:08:31 -0700 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-09-11 18:35:29 -0700 |
commit | 0d2154646ff88ce1cbd309076e6941b1ca7eae0e (patch) | |
tree | 04235db7477f8dc692a82ad92964fa7c5918dbb1 /lib/ansible | |
parent | b4e4a443149309e96a7e1846363477f84cb82411 (diff) | |
download | ansible-0d2154646ff88ce1cbd309076e6941b1ca7eae0e.tar.gz |
Port ansible doc for plugins to use DOCUMENTATION variables
* Using docstrings conflicts with the standard use of docstrings
* PYTHON_OPTIMIZE=2 will omit docstrings. Using docstrings makes future
changes to the plugin and module code subject to the requirement that we
ensure it won't be run with optimization.
(cherry picked from commit cc343a4376a27927e0c7d31862dbb3108e101978)
Diffstat (limited to 'lib/ansible')
68 files changed, 362 insertions, 406 deletions
diff --git a/lib/ansible/parsing/plugin_docs.py b/lib/ansible/parsing/plugin_docs.py index 7512b46ef4..267d612627 100644 --- a/lib/ansible/parsing/plugin_docs.py +++ b/lib/ansible/parsing/plugin_docs.py @@ -24,18 +24,6 @@ def read_docstring(filename, verbose=True, ignore_errors=True): Parse DOCUMENTATION from YAML and return the YAML doc or None together with EXAMPLES, as plain text. """ - # FIXME: Should refactor this so that we have a docstring parsing - # function and a separate variable parsing function - # Can have a function one higher that invokes whichever is needed - # - # Should look roughly like this: - # get_plugin_doc(filename, verbose=False) - # documentation = extract_docstring(plugin_ast, identifier, verbose=False) - # if not documentation and not (filter or test): - # documentation = extract_variables(plugin_ast) - # documentation['metadata'] = extract_metadata(plugin_ast) - # return documentation - data = { 'doc': None, 'plainexamples': None, @@ -52,40 +40,29 @@ def read_docstring(filename, verbose=True, ignore_errors=True): try: b_module_data = open(filename, 'rb').read() M = ast.parse(b_module_data) - try: - display.debug('Attempt first docstring is yaml docs') - docstring = yaml.load(M.body[0].value.s) - for string in string_to_vars.keys(): - if string in docstring: - data[string_to_vars[string]] = docstring[string] - display.debug('assigned :%s' % string_to_vars[string]) - except Exception as e: - display.debug('failed docstring parsing: %s' % str(e)) - if 'docs' not in data or not data['docs']: - display.debug('Fallback to vars parsing') - for child in M.body: - if isinstance(child, ast.Assign): - for t in child.targets: - try: - theid = t.id - except AttributeError: - # skip errors can happen when trying to use the normal code - display.warning("Failed to assign id for %s on %s, skipping" % (t, filename)) - continue + for child in M.body: + if isinstance(child, ast.Assign): + for t in child.targets: + try: + theid = t.id + except AttributeError: + # skip errors can happen when trying to use the normal code + display.warning("Failed to assign id for %s on %s, skipping" % (t, filename)) + continue - if theid in string_to_vars: - varkey = string_to_vars[theid] - if isinstance(child.value, ast.Dict): - data[varkey] = ast.literal_eval(child.value) + if theid in string_to_vars: + varkey = string_to_vars[theid] + if isinstance(child.value, ast.Dict): + data[varkey] = ast.literal_eval(child.value) + else: + if theid == 'DOCUMENTATION': + # string should be yaml + data[varkey] = AnsibleLoader(child.value.s, file_name=filename).get_single_data() else: - if theid == 'DOCUMENTATION': - # string should be yaml - data[varkey] = AnsibleLoader(child.value.s, file_name=filename).get_single_data() - else: - # not yaml, should be a simple string - data[varkey] = child.value.s - display.debug('assigned :%s' % varkey) + # not yaml, should be a simple string + data[varkey] = child.value.s + display.debug('assigned :%s' % varkey) # Metadata is per-file and a dict rather than per-plugin/function and yaml data['metadata'] = extract_metadata(module_ast=M)[0] diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py index c387676f39..4c9f553173 100644 --- a/lib/ansible/plugins/cache/jsonfile.py +++ b/lib/ansible/plugins/cache/jsonfile.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' cache: jsonfile short_description: JSON formatted files. description: @@ -39,10 +42,6 @@ DOCUMENTATION: type: integer ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import codecs try: diff --git a/lib/ansible/plugins/cache/memcached.py b/lib/ansible/plugins/cache/memcached.py index dca0b48066..04f7f3248d 100644 --- a/lib/ansible/plugins/cache/memcached.py +++ b/lib/ansible/plugins/cache/memcached.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' cache: memcached short_description: Use memcached DB for cache description: @@ -40,9 +42,6 @@ DOCUMENTATION: type: integer ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import collections import os import time diff --git a/lib/ansible/plugins/cache/memory.py b/lib/ansible/plugins/cache/memory.py index d0ecc65d28..1bccd544b2 100644 --- a/lib/ansible/plugins/cache/memory.py +++ b/lib/ansible/plugins/cache/memory.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' cache: memory short_description: RAM backed, non persistent description: @@ -14,10 +17,6 @@ DOCUMENTATION: author: core team (@ansible-core) ''' - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.plugins.cache import BaseCacheModule diff --git a/lib/ansible/plugins/cache/pickle.py b/lib/ansible/plugins/cache/pickle.py index 489acc2ec6..703cc1cae4 100644 --- a/lib/ansible/plugins/cache/pickle.py +++ b/lib/ansible/plugins/cache/pickle.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' cache: pickle short_description: Pickle formatted files. description: @@ -38,10 +41,6 @@ DOCUMENTATION: section: defaults ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - try: import cPickle as pickle except ImportError: diff --git a/lib/ansible/plugins/cache/redis.py b/lib/ansible/plugins/cache/redis.py index 0f4fb4f5fe..831ff037e4 100644 --- a/lib/ansible/plugins/cache/redis.py +++ b/lib/ansible/plugins/cache/redis.py @@ -1,8 +1,10 @@ # (c) 2014, Brian Coca, Josh Drake, et al # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' cache: redis short_description: Use Redis DB for cache description: @@ -37,8 +39,6 @@ DOCUMENTATION: section: defaults type: integer ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import time import json diff --git a/lib/ansible/plugins/cache/yaml.py b/lib/ansible/plugins/cache/yaml.py index bf151fef61..f66fa63b60 100644 --- a/lib/ansible/plugins/cache/yaml.py +++ b/lib/ansible/plugins/cache/yaml.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' cache: yaml short_description: YAML formatted files. description: @@ -39,10 +42,6 @@ DOCUMENTATION: type: integer ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import codecs diff --git a/lib/ansible/plugins/callback/actionable.py b/lib/ansible/plugins/callback/actionable.py index 5f0995d62e..d738db0cda 100644 --- a/lib/ansible/plugins/callback/actionable.py +++ b/lib/ansible/plugins/callback/actionable.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: actionable type: stdout short_description: shows only items that need attention @@ -14,9 +17,6 @@ DOCUMENTATION: requirements: - set as stdout callback in configuration ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from ansible.plugins.callback.default import CallbackModule as CallbackModule_default diff --git a/lib/ansible/plugins/callback/context_demo.py b/lib/ansible/plugins/callback/context_demo.py index 08add61625..0229d4ea46 100644 --- a/lib/ansible/plugins/callback/context_demo.py +++ b/lib/ansible/plugins/callback/context_demo.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: context_demo type: aggregate short_description: demo callback that adds play/task context @@ -15,9 +17,6 @@ DOCUMENTATION: - whitelist in configuration ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.plugins.callback import CallbackBase diff --git a/lib/ansible/plugins/callback/debug.py b/lib/ansible/plugins/callback/debug.py index 94e7b86c14..3d5969f648 100644 --- a/lib/ansible/plugins/callback/debug.py +++ b/lib/ansible/plugins/callback/debug.py @@ -1,8 +1,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: debug type: stdout short_description: formated stdout/stderr display @@ -12,8 +14,6 @@ DOCUMENTATION: requirements: - set as stdout in configuration ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from ansible.plugins.callback.default import CallbackModule as CallbackModule_default diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index 033cbbde44..23c10a73ec 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: default type: stdout short_description: default Ansible screen output @@ -35,9 +37,6 @@ DOCUMENTATION: - set as stdout in configuration ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible import constants as C from ansible.playbook.task_include import TaskInclude from ansible.plugins.callback import CallbackBase diff --git a/lib/ansible/plugins/callback/dense.py b/lib/ansible/plugins/callback/dense.py index 7adbdb819c..4694b76ada 100644 --- a/lib/ansible/plugins/callback/dense.py +++ b/lib/ansible/plugins/callback/dense.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: dense type: stdout short_description: minimal stdout output @@ -13,8 +15,6 @@ DOCUMENTATION: requirements: - set as stdout in configuation ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from collections import MutableMapping, MutableSequence diff --git a/lib/ansible/plugins/callback/foreman.py b/lib/ansible/plugins/callback/foreman.py index 0172b4c43c..c686d3c9ce 100644 --- a/lib/ansible/plugins/callback/foreman.py +++ b/lib/ansible/plugins/callback/foreman.py @@ -4,8 +4,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: foreman type: notification short_description: Sends events to Foreman @@ -38,9 +40,6 @@ DOCUMENTATION: - name: FOREMAN_SSL_VERIFY ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os from datetime import datetime from collections import defaultdict diff --git a/lib/ansible/plugins/callback/full_skip.py b/lib/ansible/plugins/callback/full_skip.py index dd2e8876f9..fdb8a6d410 100644 --- a/lib/ansible/plugins/callback/full_skip.py +++ b/lib/ansible/plugins/callback/full_skip.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: full_skip type: stdout short_description: suppreses tasks if all hosts skipped @@ -13,9 +16,6 @@ DOCUMENTATION: requirements: - set as stdout in configuation ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from ansible.plugins.callback.default import CallbackModule as CallbackModule_default diff --git a/lib/ansible/plugins/callback/hipchat.py b/lib/ansible/plugins/callback/hipchat.py index 55ff0ac93b..8280f2ff05 100644 --- a/lib/ansible/plugins/callback/hipchat.py +++ b/lib/ansible/plugins/callback/hipchat.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: hipchat type: notification short_description: post task events to hipchat @@ -37,9 +39,6 @@ DOCUMENTATION: - name: HIPCHAT_NOTIFY ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os try: diff --git a/lib/ansible/plugins/callback/jabber.py b/lib/ansible/plugins/callback/jabber.py index 89983d7d37..e5777ddf07 100644 --- a/lib/ansible/plugins/callback/jabber.py +++ b/lib/ansible/plugins/callback/jabber.py @@ -2,8 +2,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: jabber type: notification short_description: post task events to a jabber server @@ -36,9 +38,6 @@ DOCUMENTATION: - name: JABBER_TO ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os HAS_XMPP = True diff --git a/lib/ansible/plugins/callback/json.py b/lib/ansible/plugins/callback/json.py index 464605fe2f..cf359f9285 100644 --- a/lib/ansible/plugins/callback/json.py +++ b/lib/ansible/plugins/callback/json.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: json short_description: Ansbile screen output as JSON version_added: "2.2" @@ -14,10 +17,6 @@ DOCUMENTATION: - Set as stdout in config ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import json from ansible.plugins.callback import CallbackBase diff --git a/lib/ansible/plugins/callback/junit.py b/lib/ansible/plugins/callback/junit.py index b7255ebf7a..4948426fcb 100644 --- a/lib/ansible/plugins/callback/junit.py +++ b/lib/ansible/plugins/callback/junit.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: junit type: aggregate short_description: write playbook output to a JUnit file. @@ -40,9 +42,6 @@ DOCUMENTATION: - junit_xml (python lib) ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os import time import re diff --git a/lib/ansible/plugins/callback/log_plays.py b/lib/ansible/plugins/callback/log_plays.py index cfa65a87ee..5b9d1b96c0 100644 --- a/lib/ansible/plugins/callback/log_plays.py +++ b/lib/ansible/plugins/callback/log_plays.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: log_plays type: notification short_description: write playbook output to log file @@ -16,9 +18,6 @@ DOCUMENTATION: - A writeable /var/log/ansible/hosts directory by the user executing Ansbile on the controller ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os import time import json diff --git a/lib/ansible/plugins/callback/logentries.py b/lib/ansible/plugins/callback/logentries.py index 8f0d73b878..980f2a7aed 100644 --- a/lib/ansible/plugins/callback/logentries.py +++ b/lib/ansible/plugins/callback/logentries.py @@ -1,9 +1,10 @@ # (c) 2015, Logentries.com, Jimmy Tang <jimmy.tang@logentries.com> # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type -''' -DOCUMENTATION: +DOCUMENTATION = ''' callback: logentries type: notification short_description: Sends events to Logentries @@ -68,7 +69,10 @@ DOCUMENTATION: ini: - section: callback_logentries key: flatten -EXAMPLES: > +''' + +EXAMPLES = ''' +examples: > To enable, add this to your ansible.cfg file in the defaults block [defaults] @@ -88,8 +92,6 @@ EXAMPLES: > token = dd21fc88-f00a-43ff-b977-e3a4233c53af flatten = False ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os import socket @@ -112,10 +114,9 @@ except ImportError: from ansible.errors import AnsibleError from ansible.module_utils._text import to_bytes, to_text, to_native from ansible.plugins.callback import CallbackBase -""" -Todo: - * Better formatting of output before sending out to logentries data/api nodes. -""" + +# Todo: +# * Better formatting of output before sending out to logentries data/api nodes. class PlainTextSocketAppender(object): diff --git a/lib/ansible/plugins/callback/logstash.py b/lib/ansible/plugins/callback/logstash.py index bc3e24f6e6..ac9452ed85 100644 --- a/lib/ansible/plugins/callback/logstash.py +++ b/lib/ansible/plugins/callback/logstash.py @@ -2,8 +2,10 @@ # (C) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: logstash type: notification short_description: Sends events to Logstash @@ -31,9 +33,6 @@ DOCUMENTATION: default: ansible ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os import json import socket diff --git a/lib/ansible/plugins/callback/mail.py b/lib/ansible/plugins/callback/mail.py index bd186205ef..4101120c77 100644 --- a/lib/ansible/plugins/callback/mail.py +++ b/lib/ansible/plugins/callback/mail.py @@ -2,8 +2,10 @@ # Copyright: (c) 2012, Dag Wieers <dag@wieers.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: mail type: notification short_description: Sends failure events via email @@ -23,9 +25,6 @@ DOCUMENTATION: - "TODO: expand configuration options now that plugins can leverage Ansible's configuration" ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import json import os import smtplib diff --git a/lib/ansible/plugins/callback/minimal.py b/lib/ansible/plugins/callback/minimal.py index eb6bd5c5aa..5b568b0977 100644 --- a/lib/ansible/plugins/callback/minimal.py +++ b/lib/ansible/plugins/callback/minimal.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: minimal type: stdout short_description: minimal Ansible screen output @@ -12,11 +15,6 @@ DOCUMENTATION: - This is the default output callback used by the ansible command (ad-hoc) ''' -# Make coding more python3-ish -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.plugins.callback import CallbackBase from ansible import constants as C diff --git a/lib/ansible/plugins/callback/oneline.py b/lib/ansible/plugins/callback/oneline.py index e55856d6a5..119b8273ed 100644 --- a/lib/ansible/plugins/callback/oneline.py +++ b/lib/ansible/plugins/callback/oneline.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: oneline type: stdout short_description: oneline Ansible screen output @@ -12,10 +15,6 @@ DOCUMENTATION: - This is the output callback used by the -o/--one-line command line option. ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.plugins.callback import CallbackBase from ansible import constants as C diff --git a/lib/ansible/plugins/callback/osx_say.py b/lib/ansible/plugins/callback/osx_say.py index 1b4b490146..476c66228a 100644 --- a/lib/ansible/plugins/callback/osx_say.py +++ b/lib/ansible/plugins/callback/osx_say.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: osx_say type: notification requirements: @@ -15,10 +18,6 @@ DOCUMENTATION: - This plugin will use the 'say' program to "speak" about play events. ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import subprocess import os diff --git a/lib/ansible/plugins/callback/profile_roles.py b/lib/ansible/plugins/callback/profile_roles.py index fd4333ff4d..e13cb29fc5 100644 --- a/lib/ansible/plugins/callback/profile_roles.py +++ b/lib/ansible/plugins/callback/profile_roles.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: profile_roles type: aggregate short_description: adds timing information to roles @@ -14,12 +17,6 @@ DOCUMENTATION: - whitelisting in configuration ''' -# Make coding more python3-ish -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) - -__metaclass__ = type - import collections import time diff --git a/lib/ansible/plugins/callback/profile_tasks.py b/lib/ansible/plugins/callback/profile_tasks.py index cb97a2d356..026cf3e360 100644 --- a/lib/ansible/plugins/callback/profile_tasks.py +++ b/lib/ansible/plugins/callback/profile_tasks.py @@ -5,8 +5,11 @@ # (C) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: profile_tasks type: aggregate short_description: adds time information to tasks @@ -38,7 +41,9 @@ DOCUMENTATION: ini: - section: callback_profile_tasks key: sort_order -#EXAMPLES: > ' +''' + +EXAMPLES = ''' # # TASK: [ensure messaging security group exists] ******************************** # Thursday 11 June 2017 22:50:53 +0100 (0:00:00.721) 0:00:05.322 ********* @@ -50,11 +55,6 @@ DOCUMENTATION: # ' ''' -# Make coding more python3-ish -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import collections import time diff --git a/lib/ansible/plugins/callback/selective.py b/lib/ansible/plugins/callback/selective.py index d61eb06764..4785129011 100644 --- a/lib/ansible/plugins/callback/selective.py +++ b/lib/ansible/plugins/callback/selective.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ callback: selective callback_type: stdout requirements: @@ -26,21 +28,20 @@ DOCUMENTATION: - section: defaults - key: nocolor type: boolean -EXAMPLES: +""" + +EXAMPLES = """ - debug: msg="This will not be printed" - debug: msg="But this will" tags: [print_action] """ -from __future__ import (absolute_import, division, print_function) - import difflib from ansible import constants as C from ansible.plugins.callback import CallbackBase from ansible.module_utils._text import to_text -__metaclass__ = type DONT_COLORIZE = False COLORS = { diff --git a/lib/ansible/plugins/callback/skippy.py b/lib/ansible/plugins/callback/skippy.py index 522233fe34..bf7745cf27 100644 --- a/lib/ansible/plugins/callback/skippy.py +++ b/lib/ansible/plugins/callback/skippy.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: skippy callback_type: stdout requirements: @@ -14,10 +17,6 @@ DOCUMENTATION: - This callback does the same as the default except it does not output skipped host/task/item status ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.plugins.callback.default import CallbackModule as CallbackModule_default diff --git a/lib/ansible/plugins/callback/slack.py b/lib/ansible/plugins/callback/slack.py index a4bf4ef8ad..0ac74de31a 100644 --- a/lib/ansible/plugins/callback/slack.py +++ b/lib/ansible/plugins/callback/slack.py @@ -2,8 +2,11 @@ # (C) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: slack callback_type: notification requirements: @@ -40,9 +43,6 @@ DOCUMENTATION: - section: callback_slack key: username ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import json import os diff --git a/lib/ansible/plugins/callback/stderr.py b/lib/ansible/plugins/callback/stderr.py index 5afde9f92d..fcf53850d2 100644 --- a/lib/ansible/plugins/callback/stderr.py +++ b/lib/ansible/plugins/callback/stderr.py @@ -2,8 +2,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: stderr callback_type: stdout requirements: @@ -14,9 +17,6 @@ DOCUMENTATION: - This is the stderr callback plugin, it behaves like the default callback plugin but sends error output to stderr. - Also it does not output skipped host/task/item status ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from ansible import constants as C from ansible.plugins.callback.default import CallbackModule as CallbackModule_default diff --git a/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py index 6d0d1446a7..6385e65550 100644 --- a/lib/ansible/plugins/callback/syslog_json.py +++ b/lib/ansible/plugins/callback/syslog_json.py @@ -1,8 +1,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: syslog_json callback_type: notification requirements: @@ -39,10 +42,6 @@ DOCUMENTATION: key: syslog_facility ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os import json diff --git a/lib/ansible/plugins/callback/timer.py b/lib/ansible/plugins/callback/timer.py index f2657e0b53..c3dce219d0 100644 --- a/lib/ansible/plugins/callback/timer.py +++ b/lib/ansible/plugins/callback/timer.py @@ -1,7 +1,11 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: timer callback_type: aggregate requirements: @@ -11,9 +15,6 @@ DOCUMENTATION: description: - This callback just adds total play duration to the play stats. ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from datetime import datetime diff --git a/lib/ansible/plugins/callback/tree.py b/lib/ansible/plugins/callback/tree.py index a0918357b4..6596704919 100644 --- a/lib/ansible/plugins/callback/tree.py +++ b/lib/ansible/plugins/callback/tree.py @@ -1,8 +1,11 @@ # (c) 2012-2014, Ansible, Inc # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' callback: tree callback_type: notification requirements: @@ -13,8 +16,6 @@ DOCUMENTATION: - "This callback is used by the Ansible (adhoc) command line option `-t|--tree`" - This produces a JSON dump of events in a directory, a file for each host, the directory used MUST be passed as a commadn line option. ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os diff --git a/lib/ansible/plugins/connection/accelerate.py b/lib/ansible/plugins/connection/accelerate.py index b91fe12d1e..4e6e3884e7 100644 --- a/lib/ansible/plugins/connection/accelerate.py +++ b/lib/ansible/plugins/connection/accelerate.py @@ -14,8 +14,10 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Core Team connection: accelerate short_description: Temporary 0mq agent @@ -27,9 +29,6 @@ DOCUMENTATION: alternative: paramiko and ssh with conrol persistence. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import base64 import json import os diff --git a/lib/ansible/plugins/connection/buildah.py b/lib/ansible/plugins/connection/buildah.py index ba634f8c71..37d0326a12 100644 --- a/lib/ansible/plugins/connection/buildah.py +++ b/lib/ansible/plugins/connection/buildah.py @@ -7,8 +7,11 @@ # # Written by: Tomas Tomecek (https://github.com/TomasTomecek) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +DOCUMENTATION = """ connection: buildah short_description: Interact with an existing buildah container description: @@ -38,8 +41,6 @@ DOCUMENTATION: # - name: remote_user """ -from __future__ import (absolute_import, division, print_function) - import shlex import shutil @@ -57,9 +58,6 @@ except ImportError: display = Display() -__metaclass__ = type - - # this _has to be_ named Connection class Connection(ConnectionBase): """ diff --git a/lib/ansible/plugins/connection/chroot.py b/lib/ansible/plugins/connection/chroot.py index f2a1aa2b45..e0b5a1ed5d 100644 --- a/lib/ansible/plugins/connection/chroot.py +++ b/lib/ansible/plugins/connection/chroot.py @@ -5,8 +5,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Maykel Moya <mmoya@speedyrails.com> connection: chroot short_description: Interact with local chroot @@ -32,9 +34,6 @@ DOCUMENTATION: - name: ansible_executable """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import distutils.spawn import os import os.path diff --git a/lib/ansible/plugins/connection/docker.py b/lib/ansible/plugins/connection/docker.py index 21ca34957c..bf7d629960 100644 --- a/lib/ansible/plugins/connection/docker.py +++ b/lib/ansible/plugins/connection/docker.py @@ -6,8 +6,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: - Lorin Hochestein - Leendert Brouwer @@ -37,9 +39,6 @@ DOCUMENTATION: - name: ansible_docker_host """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import distutils.spawn import os import os.path diff --git a/lib/ansible/plugins/connection/funcd.py b/lib/ansible/plugins/connection/funcd.py index 6cc9f3f422..0562e3afd9 100644 --- a/lib/ansible/plugins/connection/funcd.py +++ b/lib/ansible/plugins/connection/funcd.py @@ -4,8 +4,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Michael Scherer (@msherer) <misc@zarb.org> connection: funcd short_description: Use funcd to connect to target @@ -23,8 +25,6 @@ DOCUMENTATION: - name: ansible_host - name: ansible_func_host """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type HAVE_FUNC = False try: diff --git a/lib/ansible/plugins/connection/iocage.py b/lib/ansible/plugins/connection/iocage.py index d196cd2d91..6c0e7e050e 100644 --- a/lib/ansible/plugins/connection/iocage.py +++ b/lib/ansible/plugins/connection/iocage.py @@ -5,8 +5,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Stephan Lohse <dev-github@ploek.org> connection: iocage short_description: Run tasks in iocage jails @@ -28,8 +30,6 @@ DOCUMENTATION: - name: ansible_user - name: ansible_iocage_user """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import subprocess from ansible.plugins.connection.jail import Connection as Jail diff --git a/lib/ansible/plugins/connection/jail.py b/lib/ansible/plugins/connection/jail.py index 50ed38df54..ca4f72dd71 100644 --- a/lib/ansible/plugins/connection/jail.py +++ b/lib/ansible/plugins/connection/jail.py @@ -5,8 +5,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Core Team connection: jail short_description: Run tasks in jails @@ -29,9 +31,6 @@ DOCUMENTATION: - name: ansible_jail_user """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import distutils.spawn import os import os.path diff --git a/lib/ansible/plugins/connection/libvirt_lxc.py b/lib/ansible/plugins/connection/libvirt_lxc.py index 96085afe6c..0cc8940bb7 100644 --- a/lib/ansible/plugins/connection/libvirt_lxc.py +++ b/lib/ansible/plugins/connection/libvirt_lxc.py @@ -5,8 +5,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Michael Scherer <misc@zarb.org> connection: libvirt_lxc short_description: Run tasks in lxc containers via libvirt @@ -23,9 +25,6 @@ DOCUMENTATION: - name: ansible_libvirt_lxc_host """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import distutils.spawn import os import os.path diff --git a/lib/ansible/plugins/connection/local.py b/lib/ansible/plugins/connection/local.py index 005185fb60..be0bfaae25 100644 --- a/lib/ansible/plugins/connection/local.py +++ b/lib/ansible/plugins/connection/local.py @@ -15,8 +15,10 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' connection: local short_description: execute on controller description: @@ -27,9 +29,6 @@ DOCUMENTATION: - The remote user is ignored, the user with which the ansible CLI was executed is used instead. ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os import shutil import subprocess diff --git a/lib/ansible/plugins/connection/lxc.py b/lib/ansible/plugins/connection/lxc.py index c7c51a20af..a8af7785e9 100644 --- a/lib/ansible/plugins/connection/lxc.py +++ b/lib/ansible/plugins/connection/lxc.py @@ -2,8 +2,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Joerg Thalheim <joerg@higgsboson.tk> connection: lxc short_description: Run tasks in lxc containers via lxc python library @@ -27,9 +29,6 @@ DOCUMENTATION: - name: ansible_lxc_executable """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os import shutil import traceback diff --git a/lib/ansible/plugins/connection/lxd.py b/lib/ansible/plugins/connection/lxd.py index ced61d9045..9cc8b8929c 100644 --- a/lib/ansible/plugins/connection/lxd.py +++ b/lib/ansible/plugins/connection/lxd.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Matt Clay <matt@mystile.com> connection: lxd short_description: Run tasks in lxc containers via lxc CLI @@ -27,9 +29,6 @@ DOCUMENTATION: - name: ansible_lxd_executable """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os from distutils.spawn import find_executable from subprocess import call, Popen, PIPE diff --git a/lib/ansible/plugins/connection/netconf.py b/lib/ansible/plugins/connection/netconf.py index 854c0bb6f6..5c73c343b4 100644 --- a/lib/ansible/plugins/connection/netconf.py +++ b/lib/ansible/plugins/connection/netconf.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Networking Team connection: netconf short_description: Use netconf to run command on network appliances @@ -66,8 +68,6 @@ DOCUMENTATION: #look_for_keys=C.PARAMIKO_LOOK_FOR_KEYS, #allow_agent=self.allow_agent, """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os import logging diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py index 0525809f57..3fc730a225 100644 --- a/lib/ansible/plugins/connection/network_cli.py +++ b/lib/ansible/plugins/connection/network_cli.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Networking Team connection: network_cli short_description: Use network_cli to run command on network appliances @@ -42,9 +44,6 @@ DOCUMENTATION: default: 120 """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import json import logging import re diff --git a/lib/ansible/plugins/connection/paramiko_ssh.py b/lib/ansible/plugins/connection/paramiko_ssh.py index a6d0e5c377..924addb6f5 100644 --- a/lib/ansible/plugins/connection/paramiko_ssh.py +++ b/lib/ansible/plugins/connection/paramiko_ssh.py @@ -1,8 +1,10 @@ # (c) 2012, Michael DeHaan <michael.dehaan@gmail.com> # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Core Team connection: paramiko short_description: Run tasks via python ssh (paramiko) @@ -47,8 +49,6 @@ DOCUMENTATION: #C.PARAMIKO_PTY #C.PARAMIKO_RECORD_HOST_KEYS """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import warnings import os diff --git a/lib/ansible/plugins/connection/persistent.py b/lib/ansible/plugins/connection/persistent.py index 6abdf00d7d..1e51eceed2 100644 --- a/lib/ansible/plugins/connection/persistent.py +++ b/lib/ansible/plugins/connection/persistent.py @@ -2,8 +2,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Core Team connection: persistent short_description: Use a persistent unix socket for connection @@ -12,9 +14,6 @@ DOCUMENTATION: version_added: "2.3" """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import re import os import pty diff --git a/lib/ansible/plugins/connection/saltstack.py b/lib/ansible/plugins/connection/saltstack.py index fb262db5db..7e32a6a281 100644 --- a/lib/ansible/plugins/connection/saltstack.py +++ b/lib/ansible/plugins/connection/saltstack.py @@ -5,8 +5,10 @@ # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Michael Scherer <misc@zarb.org> connection: saltstack short_description: Allow ansible to piggyback on salt minions @@ -15,9 +17,6 @@ DOCUMENTATION: version_added: "2.2" """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import re import os import pty diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 7280489168..1755c64a66 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -4,8 +4,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' connection: ssh short_description: connect via ssh client binary description: @@ -169,9 +171,6 @@ DOCUMENTATION: - {key: scp_if_ssh, section: ssh_connection} ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import errno import fcntl import hashlib diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index 1243023f2b..4c9a1093e3 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -2,8 +2,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Core Team connection: winrm short_description: Run tasks over Microsoft's WinRM @@ -26,9 +28,6 @@ DOCUMENTATION: - name: ansible_winrm_user """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import base64 import inspect import os diff --git a/lib/ansible/plugins/connection/zone.py b/lib/ansible/plugins/connection/zone.py index 62238195f3..ea625df410 100644 --- a/lib/ansible/plugins/connection/zone.py +++ b/lib/ansible/plugins/connection/zone.py @@ -6,8 +6,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ author: Ansible Core Team connection: zone short_description: Run tasks in a zone instance @@ -24,9 +26,6 @@ DOCUMENTATION: - name: ansible_zone_host """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import distutils.spawn import os import os.path diff --git a/lib/ansible/plugins/inventory/advanced_host_list.py b/lib/ansible/plugins/inventory/advanced_host_list.py index a4c6934351..1783efa961 100644 --- a/lib/ansible/plugins/inventory/advanced_host_list.py +++ b/lib/ansible/plugins/inventory/advanced_host_list.py @@ -1,25 +1,26 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' inventory: advanced_host_list version_added: "2.4" short_description: Parses a 'host list' with ranges description: - Parses a host list string as a comma separated values of hosts and supports host ranges. - This plugin only applies to inventory sources that are not paths and contain at least one comma. -EXAMPLES: | +''' + +EXAMPLES = ''' # simple range - ansible -i 'host[1:10],' -m ping + # ansible -i 'host[1:10],' -m ping # still supports w/o ranges also - ansible-playbook -i 'localhost,' play.yml + # ansible-playbook -i 'localhost,' play.yml ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os from ansible.errors import AnsibleError, AnsibleParserError diff --git a/lib/ansible/plugins/inventory/constructed.py b/lib/ansible/plugins/inventory/constructed.py index 72d112e010..814c67a4f9 100644 --- a/lib/ansible/plugins/inventory/constructed.py +++ b/lib/ansible/plugins/inventory/constructed.py @@ -1,8 +1,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' name: constructed plugin_type: inventory version_added: "2.4" @@ -15,7 +17,10 @@ DOCUMENTATION: - Failed expressions will be ignored (assumes vars were missing). extends_documentation_fragment: - constructed -EXAMPLES: | # inventory.config file in YAML format +''' + +EXAMPLES = ''' + # inventory.config file in YAML format plugin: comstructed compose: var_sum: var1 + var2 @@ -42,9 +47,6 @@ EXAMPLES: | # inventory.config file in YAML format key: ec2_architecture ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os from ansible.errors import AnsibleParserError diff --git a/lib/ansible/plugins/inventory/host_list.py b/lib/ansible/plugins/inventory/host_list.py index 6b1a8b8104..b9bfa9dbd5 100644 --- a/lib/ansible/plugins/inventory/host_list.py +++ b/lib/ansible/plugins/inventory/host_list.py @@ -1,28 +1,29 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -r''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = r''' inventory: host_list version_added: "2.4" short_description: Parses a 'host list' string description: - Parses a host list string as a comma separated values of hosts - This plugin only applies to inventory strings that are not paths and contain a comma. -EXAMPLES: | +''' + +EXAMPLES = r''' # define 2 hosts in command line - ansible -i '10.10.2.6, 10.10.2.4' -m ping all + # ansible -i '10.10.2.6, 10.10.2.4' -m ping all # DNS resolvable names - ansible -i 'host1.example.com, host2' -m user -a 'name=me state=absent' all + # ansible -i 'host1.example.com, host2' -m user -a 'name=me state=absent' all # just use localhost - ansible-playbook -i 'localhost,' play.yml -c local + # ansible-playbook -i 'localhost,' play.yml -c local ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os from ansible.errors import AnsibleError, AnsibleParserError diff --git a/lib/ansible/plugins/inventory/ini.py b/lib/ansible/plugins/inventory/ini.py index a84cdeee19..8033ccf315 100644 --- a/lib/ansible/plugins/inventory/ini.py +++ b/lib/ansible/plugins/inventory/ini.py @@ -1,8 +1,9 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type -''' -DOCUMENTATION: +DOCUMENTATION = ''' inventory: ini version_added: "2.4" short_description: Uses an Ansible INI file as inventory source. @@ -19,8 +20,9 @@ DOCUMENTATION: notes: - It takes the place of the previously hardcoded INI inventory. - To function it requires being whitelisted in configuration. +''' -EXAMPLES: +EXAMPLES = ''' example1: | # example cfg file [web] @@ -63,8 +65,6 @@ EXAMPLES: host4 # same host as above, but member of 2 groups, will inherit vars from both # inventory hostnames are unique ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import ast import re diff --git a/lib/ansible/plugins/inventory/openstack.py b/lib/ansible/plugins/inventory/openstack.py index 61bb642ea2..a4514b502a 100644 --- a/lib/ansible/plugins/inventory/openstack.py +++ b/lib/ansible/plugins/inventory/openstack.py @@ -5,8 +5,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' name: openstack plugin_type: inventory short_description: OpenStack inventory source @@ -84,7 +86,9 @@ DOCUMENTATION: description: Add hosts to group based on Jinja2 conditionals. type: dictionary default: {} -EXAMPLES: +''' + +EXAMPLES = ''' # file must be named openstack.yaml or openstack.yml # Make the plugin behave like the default behavior of the old script simple_config_file: @@ -93,8 +97,6 @@ simple_config_file: expand_hostvars: true fail_on_errors: true ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import collections diff --git a/lib/ansible/plugins/inventory/script.py b/lib/ansible/plugins/inventory/script.py index a85be8f768..3da241e058 100644 --- a/lib/ansible/plugins/inventory/script.py +++ b/lib/ansible/plugins/inventory/script.py @@ -2,8 +2,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' inventory: script version_added: "2.4" short_description: Executes an inventory script that returns JSON @@ -15,8 +17,6 @@ DOCUMENTATION: - It takes the place of the previously hardcoded script inventory. - To function it requires being whitelisted in configuration, which is true by default. ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os import subprocess diff --git a/lib/ansible/plugins/inventory/virtualbox.py b/lib/ansible/plugins/inventory/virtualbox.py index 5d105b984e..9efb74da77 100644 --- a/lib/ansible/plugins/inventory/virtualbox.py +++ b/lib/ansible/plugins/inventory/virtualbox.py @@ -1,8 +1,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' name: virtualbox plugin_type: inventory short_description: virtualbox inventory source @@ -32,7 +34,9 @@ DOCUMENTATION: description: add hosts to group based on Jinja2 conditionals, these also run after query block type: dictionary default: {} -EXAMPLES: +''' + +EXAMPLES = ''' # file must be named vbox.yaml or vbox.yml simple_config_file: plugin: virtualbox @@ -42,8 +46,6 @@ simple_config_file: compose: ansible_connection: ('indows' in vbox_Guest_OS)|ternary('winrm', 'ssh') ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os diff --git a/lib/ansible/plugins/inventory/yaml.py b/lib/ansible/plugins/inventory/yaml.py index 2337fcf333..560d25d96b 100644 --- a/lib/ansible/plugins/inventory/yaml.py +++ b/lib/ansible/plugins/inventory/yaml.py @@ -1,8 +1,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' inventory: yaml version_added: "2.4" short_description: Uses a specifically YAML file as inventory source. @@ -20,7 +22,8 @@ DOCUMENTATION: description: list of 'valid' extensions for files containing YAML type: list default: ['.yaml', '.yml', '.json'] -EXAMPLES: +''' +EXAMPLES = ''' all: # keys must be unique, i.e. only one 'hosts' per group hosts: test1: @@ -46,9 +49,6 @@ all: # keys must be unique, i.e. only one 'hosts' per group last_var: MYVALUE ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import re import os diff --git a/lib/ansible/plugins/lookup/cartesian.py b/lib/ansible/plugins/lookup/cartesian.py index 8b8decffae..d15bf026b8 100644 --- a/lib/ansible/plugins/lookup/cartesian.py +++ b/lib/ansible/plugins/lookup/cartesian.py @@ -14,8 +14,10 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -""" -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = """ lookup: cartesian version_added: "2.1" short_description: returns the cartesian product of lists @@ -26,7 +28,9 @@ DOCUMENTATION: description: - a set of lists required: True -EXAMPLES: +""" + +EXAMPLES = """ - name: outputs the cartesian product of the supplied lists debug: msg="{{item}}" @@ -35,15 +39,14 @@ EXAMPLES: - "{{list2}}" - name: used as lookup changes [1, 2, 3], [a, b] into [1, a], [1, b], [2, a], [2, b], [3, a], [3, b] debug: msg="{{ [1,2,3]|lookup('cartesian', [a, b])}}" +""" -RETURN: +RETURN = """ _list: description: - list of lists composed of elements of the input lists type: lists """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from itertools import product diff --git a/lib/ansible/plugins/lookup/etcd.py b/lib/ansible/plugins/lookup/etcd.py index 30b562fb30..d6b9a1d6a5 100644 --- a/lib/ansible/plugins/lookup/etcd.py +++ b/lib/ansible/plugins/lookup/etcd.py @@ -15,8 +15,10 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' author: - Jan-Piet Mens (@jpmens) lookup: etcd @@ -47,21 +49,23 @@ DOCUMENTATION: - name: ANSIBLE_ETCD_VERSION yaml: - key: etcd.version -EXAMPLES: +''' + +EXAMPLES = ''' - name: "a value from a locally running etcd" debug: msg={{ lookup('etcd', 'foo/bar') }} - name: "a values from a folder on a locally running etcd" debug: msg={{ lookup('etcd', 'foo') }} -RETURN: +''' + +RETURN = ''' _raw: description: - list of values associated with input keys type: list elements: strings ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os diff --git a/lib/ansible/plugins/lookup/mongodb.py b/lib/ansible/plugins/lookup/mongodb.py index 6f410aeb53..9df48720cf 100644 --- a/lib/ansible/plugins/lookup/mongodb.py +++ b/lib/ansible/plugins/lookup/mongodb.py @@ -15,8 +15,12 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -''' -DOCUMENTATION: + +from __future__ import (absolute_import, division, print_function) +from ansible.module_utils.six import string_types, integer_types +__metaclass__ = type + +DOCUMENTATION = ''' author: 'Marcos Diez <marcos (at) unitron.com.br>' lookup: mongodb version_added: "2.3" @@ -65,7 +69,9 @@ DOCUMENTATION: - "Please check https://api.mongodb.org/python/current/api/pymongo/collection.html?highlight=find#pymongo.collection.Collection.find for more detais." requirements: - pymongo >= 2.4 -EXAMPLES: +''' + +EXAMPLES = ''' - hosts: all gather_facts: false vars: @@ -87,12 +93,8 @@ EXAMPLES: with_mongodb: "{{mongodb_parameters}}" ''' -from __future__ import (absolute_import, division, print_function) -from ansible.module_utils.six import string_types, integer_types import datetime -__metaclass__ = type - try: from pymongo import ASCENDING, DESCENDING from pymongo.errors import ConnectionFailure diff --git a/lib/ansible/plugins/strategy/debug.py b/lib/ansible/plugins/strategy/debug.py index 0b5a1ccc4e..6146c98cf8 100644 --- a/lib/ansible/plugins/strategy/debug.py +++ b/lib/ansible/plugins/strategy/debug.py @@ -12,8 +12,10 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' strategy: debug short_description: Executes tasks in interactive debug session. description: @@ -22,9 +24,6 @@ DOCUMENTATION: author: Kishin Yagami ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import cmd import pprint import sys diff --git a/lib/ansible/plugins/strategy/free.py b/lib/ansible/plugins/strategy/free.py index 43e5c05ddd..c398c19cc4 100644 --- a/lib/ansible/plugins/strategy/free.py +++ b/lib/ansible/plugins/strategy/free.py @@ -14,8 +14,11 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' strategy: free short_description: Executes tasks on each host independently description: @@ -25,9 +28,6 @@ DOCUMENTATION: version_added: "2.0" author: Ansible Core Team ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import time diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index 05afae28ef..7ecc75b58f 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -14,8 +14,11 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -''' -DOCUMENTATION: +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' strategy: linear short_description: Executes tasks in a linear fashion description: @@ -27,9 +30,6 @@ DOCUMENTATION: - This was the default Ansible behaviour before 'strategy plugins' were introduced in 2.0. author: Ansible Core Team ''' -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type from ansible.errors import AnsibleError from ansible.executor.play_iterator import PlayIterator diff --git a/lib/ansible/plugins/vars/host_group_vars.py b/lib/ansible/plugins/vars/host_group_vars.py index bc4fd0a9dd..66c059b263 100644 --- a/lib/ansible/plugins/vars/host_group_vars.py +++ b/lib/ansible/plugins/vars/host_group_vars.py @@ -15,8 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ############################################# -''' -DOCUMENTATION: +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' vars: host_group_vars version_added: "2.4" short_description: In charge of loading group_vars and host_vars @@ -41,9 +43,6 @@ DOCUMENTATION: type: list ''' -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import os from ansible import constants as C from ansible.errors import AnsibleParserError |