diff options
Diffstat (limited to 'lib/ansible/playbook')
25 files changed, 32 insertions, 79 deletions
diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 52b2ee7..e125df1 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os diff --git a/lib/ansible/playbook/attribute.py b/lib/ansible/playbook/attribute.py index 73e73ab..bf39755 100644 --- a/lib/ansible/playbook/attribute.py +++ b/lib/ansible/playbook/attribute.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible.utils.sentinel import Sentinel diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 81ce502..96c3b98 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -2,8 +2,7 @@ # 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 +from __future__ import annotations import itertools import operator @@ -561,7 +560,7 @@ class FieldAttributeBase: setattr(self, name, value) except (TypeError, ValueError) as e: value = getattr(self, name) - raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to an %s." + raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to %s. " "The error was: %s" % (name, value, attribute.isa, e), obj=self.get_ds(), orig_exc=e) except (AnsibleUndefinedVariable, UndefinedError) as e: if templar._fail_on_undefined_errors and name != 'name': diff --git a/lib/ansible/playbook/block.py b/lib/ansible/playbook/block.py index e585fb7..9c82ed2 100644 --- a/lib/ansible/playbook/block.py +++ b/lib/ansible/playbook/block.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import ansible.constants as C from ansible.errors import AnsibleParserError diff --git a/lib/ansible/playbook/collectionsearch.py b/lib/ansible/playbook/collectionsearch.py index 2980093..c6ab509 100644 --- a/lib/ansible/playbook/collectionsearch.py +++ b/lib/ansible/playbook/collectionsearch.py @@ -1,8 +1,7 @@ # Copyright: (c) 2019, 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 +from __future__ import annotations from ansible.module_utils.six import string_types from ansible.playbook.attribute import FieldAttribute diff --git a/lib/ansible/playbook/conditional.py b/lib/ansible/playbook/conditional.py index 449b4a9..2fb026b 100644 --- a/lib/ansible/playbook/conditional.py +++ b/lib/ansible/playbook/conditional.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import typing as t diff --git a/lib/ansible/playbook/delegatable.py b/lib/ansible/playbook/delegatable.py index 2d9d16e..ce2f025 100644 --- a/lib/ansible/playbook/delegatable.py +++ b/lib/ansible/playbook/delegatable.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright The Ansible project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import annotations from ansible.playbook.attribute import FieldAttribute diff --git a/lib/ansible/playbook/handler.py b/lib/ansible/playbook/handler.py index 2f28398..09f122e 100644 --- a/lib/ansible/playbook/handler.py +++ b/lib/ansible/playbook/handler.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible.playbook.attribute import NonInheritableFieldAttribute from ansible.playbook.task import Task @@ -36,7 +34,7 @@ class Handler(Task): super(Handler, self).__init__(block=block, role=role, task_include=task_include) def __repr__(self): - ''' returns a human readable representation of the handler ''' + ''' returns a human-readable representation of the handler ''' return "HANDLER: %s" % self.get_name() @staticmethod diff --git a/lib/ansible/playbook/handler_task_include.py b/lib/ansible/playbook/handler_task_include.py index 1c779f8..2a03881 100644 --- a/lib/ansible/playbook/handler_task_include.py +++ b/lib/ansible/playbook/handler_task_include.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations # from ansible.inventory.host import Host from ansible.playbook.handler import Handler diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index 903dcdf..91ca06f 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -15,8 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os @@ -94,7 +93,6 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h from ansible.playbook.role_include import IncludeRole from ansible.playbook.handler_task_include import HandlerTaskInclude from ansible.template import Templar - from ansible.utils.plugin_docs import get_versioned_doclink if not isinstance(ds, list): raise AnsibleAssertionError('The ds (%s) should be a list but was a %s' % (ds, type(ds))) @@ -258,7 +256,6 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h else: task_list.extend(included_blocks) else: - t.is_static = False task_list.append(t) elif action in C._ACTION_ALL_PROPER_INCLUDE_IMPORT_ROLES: diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index 925d439..d2fdb76 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os @@ -91,14 +89,16 @@ class IncludedFile: except KeyError: task_vars = task_vars_cache[cache_key] = variable_manager.get_vars(play=iterator._play, host=original_host, task=original_task) - include_args = include_result.get('include_args', dict()) + include_args = include_result.pop('include_args', dict()) special_vars = {} loop_var = include_result.get('ansible_loop_var', 'item') index_var = include_result.get('ansible_index_var') if loop_var in include_result: task_vars[loop_var] = special_vars[loop_var] = include_result[loop_var] + task_vars['ansible_loop_var'] = special_vars['ansible_loop_var'] = loop_var if index_var and index_var in include_result: task_vars[index_var] = special_vars[index_var] = include_result[index_var] + task_vars['ansible_index_var'] = special_vars['ansible_index_var'] = index_var if '_ansible_item_label' in include_result: task_vars['_ansible_item_label'] = special_vars['_ansible_item_label'] = include_result['_ansible_item_label'] if 'ansible_loop' in include_result: diff --git a/lib/ansible/playbook/loop_control.py b/lib/ansible/playbook/loop_control.py index 4df0a73..8581b1f 100644 --- a/lib/ansible/playbook/loop_control.py +++ b/lib/ansible/playbook/loop_control.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible.playbook.attribute import NonInheritableFieldAttribute from ansible.playbook.base import FieldAttributeBase diff --git a/lib/ansible/playbook/notifiable.py b/lib/ansible/playbook/notifiable.py index a183293..c66cc94 100644 --- a/lib/ansible/playbook/notifiable.py +++ b/lib/ansible/playbook/notifiable.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright The Ansible project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import annotations from ansible.playbook.attribute import FieldAttribute diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 6449859..3331a50 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible import constants as C from ansible import context diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index af65e86..0ee1109 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -17,9 +17,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible import constants as C from ansible import context diff --git a/lib/ansible/playbook/playbook_include.py b/lib/ansible/playbook/playbook_include.py index 2579a8a..613f939 100644 --- a/lib/ansible/playbook/playbook_include.py +++ b/lib/ansible/playbook/playbook_include.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os diff --git a/lib/ansible/playbook/role/__init__.py b/lib/ansible/playbook/role/__init__.py index 49254fc..1c82e53 100644 --- a/lib/ansible/playbook/role/__init__.py +++ b/lib/ansible/playbook/role/__init__.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os diff --git a/lib/ansible/playbook/role/definition.py b/lib/ansible/playbook/role/definition.py index f7ca3a8..12d6ce1 100644 --- a/lib/ansible/playbook/role/definition.py +++ b/lib/ansible/playbook/role/definition.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os diff --git a/lib/ansible/playbook/role/include.py b/lib/ansible/playbook/role/include.py index f4b3e40..934b53c 100644 --- a/lib/ansible/playbook/role/include.py +++ b/lib/ansible/playbook/role/include.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible.errors import AnsibleError, AnsibleParserError from ansible.module_utils.six import string_types diff --git a/lib/ansible/playbook/role/metadata.py b/lib/ansible/playbook/role/metadata.py index e299122..482539a 100644 --- a/lib/ansible/playbook/role/metadata.py +++ b/lib/ansible/playbook/role/metadata.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import os diff --git a/lib/ansible/playbook/role/requirement.py b/lib/ansible/playbook/role/requirement.py index 59e9cf3..d68f686 100644 --- a/lib/ansible/playbook/role/requirement.py +++ b/lib/ansible/playbook/role/requirement.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible.errors import AnsibleError from ansible.module_utils.six import string_types diff --git a/lib/ansible/playbook/role_include.py b/lib/ansible/playbook/role_include.py index cdf86c0..628f26e 100644 --- a/lib/ansible/playbook/role_include.py +++ b/lib/ansible/playbook/role_include.py @@ -14,11 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from os.path import basename +from __future__ import annotations import ansible.constants as C from ansible.errors import AnsibleParserError @@ -132,10 +128,6 @@ class IncludeRole(TaskInclude): if ir._role_name is None: raise AnsibleParserError("'name' is a required field for %s." % ir.action, obj=data) - # public is only valid argument for includes, imports are always 'public' (after they run) - if 'public' in ir.args and ir.action not in C._ACTION_INCLUDE_ROLE: - raise AnsibleParserError('Invalid options for %s: public' % ir.action, obj=data) - # validate bad args, otherwise we silently ignore bad_opts = my_arg_names.difference(IncludeRole.VALID_ARGS) if bad_opts: @@ -147,7 +139,7 @@ class IncludeRole(TaskInclude): args_value = ir.args.get(key) if not isinstance(args_value, string_types): raise AnsibleParserError('Expected a string for %s but got %s instead' % (key, type(args_value))) - ir._from_files[from_key] = basename(args_value) + ir._from_files[from_key] = args_value # apply is only valid for includes, not imports as they inherit directly apply_attrs = ir.args.get('apply', {}) diff --git a/lib/ansible/playbook/taggable.py b/lib/ansible/playbook/taggable.py index 828c7b2..fa1d5b2 100644 --- a/lib/ansible/playbook/taggable.py +++ b/lib/ansible/playbook/taggable.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible.errors import AnsibleError from ansible.module_utils.six import string_types diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index fa1114a..7f54639 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations from ansible import constants as C from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleAssertionError @@ -136,7 +134,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl return t.load_data(data, variable_manager=variable_manager, loader=loader) def __repr__(self): - ''' returns a human readable representation of the task ''' + ''' returns a human-readable representation of the task ''' if self.action in C._ACTION_META: return "TASK: meta (%s)" % self.args['_raw_params'] else: diff --git a/lib/ansible/playbook/task_include.py b/lib/ansible/playbook/task_include.py index fc09889..1ace5fd 100644 --- a/lib/ansible/playbook/task_include.py +++ b/lib/ansible/playbook/task_include.py @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import ansible.constants as C from ansible.errors import AnsibleParserError |