role now fails if specified file not found

fixes https://github.com/ansible/ansible-modules-core/issues/5166
This commit is contained in:
Brian Coca 2016-10-20 14:33:41 -04:00 committed by Brian Coca
parent 432633e4c1
commit ea428e716d

View file

@ -207,6 +207,8 @@ class Role(Base, Become, Conditional, Taggable):
main_file = self._resolve_main(file_path, main) main_file = self._resolve_main(file_path, main)
if self._loader.path_exists(main_file): if self._loader.path_exists(main_file):
return self._loader.load_from_file(main_file) return self._loader.load_from_file(main_file)
elif main is not None:
raise AnsibleParserError("Could not find specified file in role: %s" % main)
return None return None
def _resolve_main(self, basepath, main=None): def _resolve_main(self, basepath, main=None):