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

make debconf compare apples to apples (booleans) #53331

Merged
merged 1 commit into from
Mar 5, 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/debconf_bool_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Fix how debconf handles boolean questions to accurately compare
12 changes: 11 additions & 1 deletion lib/ansible/modules/system/debconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
name: tzdata
'''

from ansible.module_utils._text import to_text
from ansible.module_utils.basic import AnsibleModule


Expand Down Expand Up @@ -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:
Expand Down