mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Imports and includes (#25399)
Initial commit to split includes into static imports/dynamic includes
This implements the new include/import syntax for Ansible 2.4:
* include_{tasks,role,variables} = dynamic
* import_{playbook,tasks,role} = static
The old bare `include` will be considered deprecated, as will any use of the `static: {yes|no}` option.
This also adds docs for import/include and reorganizing the "Playbook Reuse" section of the documentation.
This commit is contained in:
@@ -27,6 +27,7 @@ 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
|
||||
from ansible.utils.color import colorize, hostcolor
|
||||
|
||||
@@ -80,7 +81,7 @@ class CallbackModule(CallbackBase):
|
||||
|
||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||
self._clean_results(result._result, result._task.action)
|
||||
if result._task.action in ('include', 'include_role'):
|
||||
if isinstance(result._task, TaskInclude):
|
||||
return
|
||||
elif result._result.get('changed', False):
|
||||
if delegated_vars:
|
||||
@@ -194,7 +195,7 @@ class CallbackModule(CallbackBase):
|
||||
|
||||
def v2_runner_item_on_ok(self, result):
|
||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||
if result._task.action in ('include', 'include_role'):
|
||||
if isinstance(result._task, TaskInclude):
|
||||
return
|
||||
elif result._result.get('changed', False):
|
||||
msg = 'changed'
|
||||
|
||||
Reference in New Issue
Block a user