1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

warn when having issues with local facts (#52507)

* warn when having issues with local facts

fixes 41609
This commit is contained in:
Brian Coca 2019-02-20 17:25:55 -05:00 committed by GitHub
parent 9d11cd311b
commit 8a0347ac7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- issue a warning when local fact is not correctly loaded, old behaviour just updated fact value with the error.

View file

@ -60,6 +60,7 @@ class LocalFactCollector(BaseFactCollector):
fact = 'error loading fact - output of running %s was not utf-8' % fn fact = 'error loading fact - output of running %s was not utf-8' % fn
local[fact_base] = fact local[fact_base] = fact
local_facts['local'] = local local_facts['local'] = local
module.warn(fact)
return local_facts return local_facts
else: else:
out = get_file_content(fn, default='') out = get_file_content(fn, default='')
@ -75,6 +76,7 @@ class LocalFactCollector(BaseFactCollector):
cp.readfp(StringIO(out)) cp.readfp(StringIO(out))
except configparser.Error: except configparser.Error:
fact = "error loading fact - please check content" fact = "error loading fact - please check content"
module.warn(fact)
else: else:
fact = {} fact = {}
for sect in cp.sections(): for sect in cp.sections():