mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
simplified inventory error messaging
This commit is contained in:
parent
e33b97ed1f
commit
4561be00af
1 changed files with 5 additions and 12 deletions
|
@ -52,6 +52,7 @@ def get_file_parser(hostsfile, groups, loader):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
#FIXME: make this 'plugin loop'
|
#FIXME: make this 'plugin loop'
|
||||||
# script
|
# script
|
||||||
if loader.is_executable(hostsfile):
|
if loader.is_executable(hostsfile):
|
||||||
|
@ -59,9 +60,9 @@ def get_file_parser(hostsfile, groups, loader):
|
||||||
parser = InventoryScript(loader=loader, groups=groups, filename=hostsfile)
|
parser = InventoryScript(loader=loader, groups=groups, filename=hostsfile)
|
||||||
processed = True
|
processed = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
myerr.append("The file %s is marked as executable, but failed to execute correctly. " % hostsfile + \
|
|
||||||
"If this is not supposed to be an executable script, correct this with `chmod -x %s`." % hostsfile)
|
|
||||||
myerr.append(str(e))
|
myerr.append(str(e))
|
||||||
|
elif shebang_present:
|
||||||
|
myerr.append("The file %s looks like it should be an executable inventory script, but is not marked executable. Perhaps you want to correct this with `chmod +x %s`?" % (hostsfile, hostsfile))
|
||||||
|
|
||||||
# YAML/JSON
|
# YAML/JSON
|
||||||
if not processed and os.path.splitext(hostsfile)[-1] in C.YAML_FILENAME_EXTENSIONS:
|
if not processed and os.path.splitext(hostsfile)[-1] in C.YAML_FILENAME_EXTENSIONS:
|
||||||
|
@ -69,10 +70,6 @@ def get_file_parser(hostsfile, groups, loader):
|
||||||
parser = InventoryYAMLParser(loader=loader, groups=groups, filename=hostsfile)
|
parser = InventoryYAMLParser(loader=loader, groups=groups, filename=hostsfile)
|
||||||
processed = True
|
processed = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if shebang_present and not loader.is_executable(hostsfile):
|
|
||||||
myerr.append("The file %s looks like it should be an executable inventory script, but is not marked executable. " % hostsfile + \
|
|
||||||
"Perhaps you want to correct this with `chmod +x %s`?" % hostsfile)
|
|
||||||
else:
|
|
||||||
myerr.append(str(e))
|
myerr.append(str(e))
|
||||||
|
|
||||||
# ini
|
# ini
|
||||||
|
@ -81,10 +78,6 @@ def get_file_parser(hostsfile, groups, loader):
|
||||||
parser = InventoryINIParser(loader=loader, groups=groups, filename=hostsfile)
|
parser = InventoryINIParser(loader=loader, groups=groups, filename=hostsfile)
|
||||||
processed = True
|
processed = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if shebang_present and not loader.is_executable(hostsfile):
|
|
||||||
myerr.append("The file %s looks like it should be an executable inventory script, but is not marked executable. " % hostsfile + \
|
|
||||||
"Perhaps you want to correct this with `chmod +x %s`?" % hostsfile)
|
|
||||||
else:
|
|
||||||
myerr.append(str(e))
|
myerr.append(str(e))
|
||||||
|
|
||||||
if not processed and myerr:
|
if not processed and myerr:
|
||||||
|
|
Loading…
Reference in a new issue