mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
account for absense of config file
This commit is contained in:
parent
dfcf43efa9
commit
6b99f0d65c
1 changed files with 12 additions and 11 deletions
|
@ -89,17 +89,18 @@ class ConfigManager(object):
|
||||||
# TODO: take list of files with merge/nomerge
|
# TODO: take list of files with merge/nomerge
|
||||||
|
|
||||||
parser = None
|
parser = None
|
||||||
if ftype == 'ini':
|
if cfile:
|
||||||
parser = configparser.ConfigParser()
|
if ftype == 'ini':
|
||||||
try:
|
parser = configparser.ConfigParser()
|
||||||
parser.read(cfile)
|
try:
|
||||||
except configparser.Error as e:
|
parser.read(cfile)
|
||||||
raise AnsibleOptionsError("Error reading config file: \n{0}".format(e))
|
except configparser.Error as e:
|
||||||
elif ftype == 'yaml':
|
raise AnsibleOptionsError("Error reading config file: \n{0}".format(e))
|
||||||
with open(cfile, 'rb') as config_stream:
|
elif ftype == 'yaml':
|
||||||
parser = yaml.safe_load(config_stream)
|
with open(cfile, 'rb') as config_stream:
|
||||||
else:
|
parser = yaml.safe_load(config_stream)
|
||||||
raise AnsibleOptionsError("Unsupported configuration file type: \n{0}".format(ftype))
|
else:
|
||||||
|
raise AnsibleOptionsError("Unsupported configuration file type: \n{0}".format(ftype))
|
||||||
|
|
||||||
self.update_config(cfile, self.initial_defs, parser, ftype)
|
self.update_config(cfile, self.initial_defs, parser, ftype)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue