From 8a0347ac7aa0a7ea32d87f70ca0b22adc05f69e0 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 20 Feb 2019 17:25:55 -0500 Subject: [PATCH] warn when having issues with local facts (#52507) * warn when having issues with local facts fixes 41609 --- changelogs/fragments/warn_bad_local_fact.yml | 2 ++ lib/ansible/module_utils/facts/system/local.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/warn_bad_local_fact.yml diff --git a/changelogs/fragments/warn_bad_local_fact.yml b/changelogs/fragments/warn_bad_local_fact.yml new file mode 100644 index 0000000000..b2724fbd8f --- /dev/null +++ b/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. diff --git a/lib/ansible/module_utils/facts/system/local.py b/lib/ansible/module_utils/facts/system/local.py index 20ba901cdb..fe33a3232f 100644 --- a/lib/ansible/module_utils/facts/system/local.py +++ b/lib/ansible/module_utils/facts/system/local.py @@ -60,6 +60,7 @@ class LocalFactCollector(BaseFactCollector): 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='') @@ -75,6 +76,7 @@ class LocalFactCollector(BaseFactCollector): cp.readfp(StringIO(out)) except configparser.Error: fact = "error loading fact - please check content" + module.warn(fact) else: fact = {} for sect in cp.sections():