optimize config yaml loading (#34481)

fixes #34147
pull/34524/head
Brian Coca 7 years ago committed by Adam Miller
parent e6a7c0e30b
commit f189106ef6

@ -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))

Loading…
Cancel
Save