summaryrefslogtreecommitdiffstats
path: root/lib/ansible/modules/debconf.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:16:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:16:49 +0000
commit48e387c5c12026a567eb7b293a3a590241c0cecb (patch)
tree80f2573be2d7d534b8ac4d2a852fe43f7ac35324 /lib/ansible/modules/debconf.py
parentReleasing progress-linux version 2.16.6-1~progress7.99u1. (diff)
downloadansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.tar.xz
ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.zip
Merging upstream version 2.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/modules/debconf.py')
-rw-r--r--lib/ansible/modules/debconf.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/ansible/modules/debconf.py b/lib/ansible/modules/debconf.py
index 5ff1402..779952e 100644
--- a/lib/ansible/modules/debconf.py
+++ b/lib/ansible/modules/debconf.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2014, Brian Coca <briancoca+ansible@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
@@ -71,12 +70,14 @@ options:
- The type of the value supplied.
- It is highly recommended to add C(no_log=True) to task while specifying O(vtype=password).
- V(seen) was added in Ansible 2.2.
+ - After Ansible 2.17, user can specify C(value) as a list, if C(vtype) is set as V(multiselect).
type: str
choices: [ boolean, error, multiselect, note, password, seen, select, string, text, title ]
value:
description:
- - Value to set the configuration to.
- type: str
+ - Value to set the configuration to.
+ - After Ansible 2.17, C(value) is of type 'raw'.
+ type: raw
aliases: [ answer ]
unseen:
description:
@@ -124,7 +125,7 @@ EXAMPLES = r'''
RETURN = r'''#'''
-from ansible.module_utils.common.text.converters import to_text
+from ansible.module_utils.common.text.converters import to_text, to_native
from ansible.module_utils.basic import AnsibleModule
@@ -185,7 +186,7 @@ def main():
name=dict(type='str', required=True, aliases=['pkg']),
question=dict(type='str', aliases=['selection', 'setting']),
vtype=dict(type='str', choices=['boolean', 'error', 'multiselect', 'note', 'password', 'seen', 'select', 'string', 'text', 'title']),
- value=dict(type='str', aliases=['answer']),
+ value=dict(type='raw', aliases=['answer']),
unseen=dict(type='bool', default=False),
),
required_together=(['question', 'vtype', 'value'],),
@@ -218,15 +219,25 @@ def main():
if vtype == 'boolean':
value = to_text(value).lower()
existing = to_text(prev[question]).lower()
-
- if vtype == 'password':
+ elif vtype == 'password':
existing = get_password_value(module, pkg, question, vtype)
+ elif vtype == 'multiselect' and isinstance(value, list):
+ try:
+ value = sorted(value)
+ except TypeError as exc:
+ module.fail_json(msg="Invalid value provided for 'multiselect': %s" % to_native(exc))
+ existing = sorted([i.strip() for i in existing.split(",")])
if value != existing:
changed = True
if changed:
if not module.check_mode:
+ if vtype == 'multiselect' and isinstance(value, list):
+ try:
+ value = ", ".join(value)
+ except TypeError as exc:
+ module.fail_json(msg="Invalid value provided for 'multiselect': %s" % to_native(exc))
rc, msg, e = set_selection(module, pkg, question, vtype, value, unseen)
if rc:
module.fail_json(msg=e)