faster config loading (#48333)

* faster config loading

  - used already loaded module var instead of doc functions
  - add preload to populate config defs cache
  - avoid debug work when not in debug
  - generators, force consumption
This commit is contained in:
Brian Coca 2019-01-23 12:06:54 -05:00 committed by GitHub
parent 9d4c0dc111
commit 960388143f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View file

@ -27,6 +27,7 @@ from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.module_utils._text import to_native, to_text
from ansible.playbook import Playbook
from ansible.template import Templar
from ansible.plugins.loader import connection_loader, shell_loader
from ansible.utils.helpers import pct_to_int
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.utils.path import makedirs_safe
@ -76,6 +77,10 @@ class PlaybookExecutor:
entrylist = []
entry = {}
try:
# preload become/connecition/shell to set config defs cached
list(connection_loader.all(class_only=True))
list(shell_loader.all(class_only=True))
for playbook_path in self._playbooks:
pb = Playbook.load(playbook_path, variable_manager=self._variable_manager, loader=self._loader)
# FIXME: move out of inventory self._inventory.set_playbook_basedir(os.path.realpath(os.path.dirname(playbook_path)))