mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Use templar all the way down
Fixes bugs related to creating Templar() objects on the fly, where the shared loader objects (serialized to TaskExecutor) aren't used so information loaded into plugin loaders after forking is lost. Fixes #11815
This commit is contained in:
parent
c3ce140dd2
commit
5266679964
15 changed files with 44 additions and 42 deletions
|
@ -26,7 +26,7 @@ from ansible.parsing import DataLoader
|
|||
from ansible.playbook.attribute import Attribute, FieldAttribute
|
||||
from ansible.playbook.play import Play
|
||||
from ansible.playbook.playbook_include import PlaybookInclude
|
||||
from ansible.plugins import push_basedir
|
||||
from ansible.plugins import get_all_plugin_loaders
|
||||
|
||||
|
||||
__all__ = ['Playbook']
|
||||
|
@ -57,8 +57,12 @@ class Playbook:
|
|||
# set the loaders basedir
|
||||
self._loader.set_basedir(self._basedir)
|
||||
|
||||
# also add the basedir to the list of module directories
|
||||
push_basedir(self._basedir)
|
||||
# dynamically load any plugins from the role directory
|
||||
for name, obj in get_all_plugin_loaders():
|
||||
if obj.subdir:
|
||||
plugin_path = os.path.join(self._basedir, obj.subdir)
|
||||
if os.path.isdir(plugin_path):
|
||||
obj.add_directory(plugin_path)
|
||||
|
||||
ds = self._loader.load_from_file(os.path.basename(file_name))
|
||||
if not isinstance(ds, list):
|
||||
|
|
|
@ -37,7 +37,7 @@ from ansible.playbook.helpers import load_list_of_blocks
|
|||
from ansible.playbook.role.include import RoleInclude
|
||||
from ansible.playbook.role.metadata import RoleMetadata
|
||||
from ansible.playbook.taggable import Taggable
|
||||
from ansible.plugins import get_all_plugin_loaders, push_basedir
|
||||
from ansible.plugins import get_all_plugin_loaders
|
||||
from ansible.utils.vars import combine_vars
|
||||
|
||||
|
||||
|
@ -142,8 +142,6 @@ class Role(Base, Become, Conditional, Taggable):
|
|||
self._variable_manager = role_include.get_variable_manager()
|
||||
self._loader = role_include.get_loader()
|
||||
|
||||
push_basedir(self._role_path)
|
||||
|
||||
if parent_role:
|
||||
self.add_parent(parent_role)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue