Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

group_vars: host_vars: warn for non-yaml files in dirs #18128

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/ansible/vars/__init__.py
Expand Up @@ -558,6 +558,10 @@ def _load_inventory_file(self, path, loader):
file_name, ext = os.path.splitext(path)
data = None
if not ext or ext not in C.YAML_FILENAME_EXTENSIONS:
# Warn for non yaml extensions or backup files
if ext or file_name.endswith('~'):
display.warning("Loaded vars in %s although the vars file has not proper name or valid extension" % (path,))

for test_ext in C.YAML_FILENAME_EXTENSIONS:
new_path = path + test_ext
if loader.path_exists(new_path):
Expand Down