From 6b99f0d65cca0d4175dff2c88757060a1c9f826e Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 14 Jun 2017 11:38:35 -0400 Subject: [PATCH] account for absense of config file --- lib/ansible/config/manager.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index 28a29865e8..88545f338f 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -89,17 +89,18 @@ class ConfigManager(object): # TODO: take list of files with merge/nomerge parser = None - if ftype == 'ini': - parser = configparser.ConfigParser() - try: - parser.read(cfile) - except configparser.Error as e: - raise AnsibleOptionsError("Error reading config file: \n{0}".format(e)) - elif ftype == 'yaml': - with open(cfile, 'rb') as config_stream: - parser = yaml.safe_load(config_stream) - else: - raise AnsibleOptionsError("Unsupported configuration file type: \n{0}".format(ftype)) + if cfile: + if ftype == 'ini': + parser = configparser.ConfigParser() + try: + parser.read(cfile) + except configparser.Error as e: + raise AnsibleOptionsError("Error reading config file: \n{0}".format(e)) + elif ftype == 'yaml': + with open(cfile, 'rb') as config_stream: + parser = yaml.safe_load(config_stream) + else: + raise AnsibleOptionsError("Unsupported configuration file type: \n{0}".format(ftype)) self.update_config(cfile, self.initial_defs, parser, ftype)