From 949ddb48c07a3f4c22ebb4fa2f5d8e0cf24e007d Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 5 Mar 2019 16:03:54 -0500 Subject: [PATCH] make debconf compare apples to apples (booleans) (#53331) hope to fix #25481 --- changelogs/fragments/debconf_bool_fix.yml | 2 ++ lib/ansible/modules/system/debconf.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/debconf_bool_fix.yml diff --git a/changelogs/fragments/debconf_bool_fix.yml b/changelogs/fragments/debconf_bool_fix.yml new file mode 100644 index 0000000000..e8fb2ef44c --- /dev/null +++ b/changelogs/fragments/debconf_bool_fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix how debconf handles boolean questions to accurately compare diff --git a/lib/ansible/modules/system/debconf.py b/lib/ansible/modules/system/debconf.py index e241c61c56..1edf6c1ac4 100644 --- a/lib/ansible/modules/system/debconf.py +++ b/lib/ansible/modules/system/debconf.py @@ -87,6 +87,7 @@ EXAMPLES = r''' name: tzdata ''' +from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule @@ -151,8 +152,17 @@ def main(): if vtype is None or value is None: module.fail_json(msg="when supplying a question you must supply a valid vtype and value") - if question not in prev or prev[question] != value: + # if question doesn't exist, value cannot match + if question not in prev: changed = True + else: + # ensure we compare booleans supplied to the way debconf sees them (true/false strings) + if vtype == 'boolean': + value = to_text(value).lower() + existing = to_text(prev[question]).lower() + + if value != existing: + changed = True if changed: if not module.check_mode: