optimize config yaml loading (#34481)

fixes #34147
This commit is contained in:
Brian Coca 2018-01-05 17:58:05 -05:00 committed by Adam Miller
parent e6a7c0e30b
commit f189106ef6

View file

@ -7,10 +7,16 @@ __metaclass__ = type
import os
import sys
import tempfile
import yaml
from collections import namedtuple
from yaml import load as yaml_load
try:
# use C version if possible for speedup
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader
from ansible.config.data import ConfigData
from ansible.errors import AnsibleOptionsError, AnsibleError
from ansible.module_utils.six import string_types
@ -181,7 +187,7 @@ class ConfigManager(object):
# consume definitions
if os.path.exists(b_defs_file):
with open(b_defs_file, 'rb') as config_def:
self._base_defs = yaml.safe_load(config_def)
self._base_defs = yaml_load(config_def, Loader=SafeLoader)
else:
raise AnsibleError("Missing base configuration definition file (bad install?): %s" % to_native(b_defs_file))