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

warn when having issues with local facts #52507

Merged
merged 2 commits into from Feb 20, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions changelogs/fragments/warn_bad_local_fact.yml
@@ -0,0 +1,2 @@
bugfixes:
- issue a warning when local fact is not correctly loaded, old behaviour just updated fact value with the error.
2 changes: 2 additions & 0 deletions lib/ansible/module_utils/facts/system/local.py
Expand Up @@ -60,6 +60,7 @@ def collect(self, module=None, collected_facts=None):
fact = 'error loading fact - output of running %s was not utf-8' % fn
local[fact_base] = fact
local_facts['local'] = local
module.warn(fact)
return local_facts
else:
out = get_file_content(fn, default='')
Expand All @@ -75,6 +76,7 @@ def collect(self, module=None, collected_facts=None):
cp.readfp(StringIO(out))
except configparser.Error:
fact = "error loading fact - please check content"
module.warn(fact)
else:
fact = {}
for sect in cp.sections():
Expand Down