|
|
@ -70,12 +70,14 @@ options:
|
|
|
|
- The type of the value supplied.
|
|
|
|
- The type of the value supplied.
|
|
|
|
- It is highly recommended to add C(no_log=True) to task while specifying O(vtype=password).
|
|
|
|
- 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.
|
|
|
|
- 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
|
|
|
|
type: str
|
|
|
|
choices: [ boolean, error, multiselect, note, password, seen, select, string, text, title ]
|
|
|
|
choices: [ boolean, error, multiselect, note, password, seen, select, string, text, title ]
|
|
|
|
value:
|
|
|
|
value:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Value to set the configuration to.
|
|
|
|
- Value to set the configuration to.
|
|
|
|
type: str
|
|
|
|
- After Ansible 2.17, C(value) is of type 'raw'.
|
|
|
|
|
|
|
|
type: raw
|
|
|
|
aliases: [ answer ]
|
|
|
|
aliases: [ answer ]
|
|
|
|
unseen:
|
|
|
|
unseen:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -123,7 +125,7 @@ EXAMPLES = r'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = 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
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -184,7 +186,7 @@ def main():
|
|
|
|
name=dict(type='str', required=True, aliases=['pkg']),
|
|
|
|
name=dict(type='str', required=True, aliases=['pkg']),
|
|
|
|
question=dict(type='str', aliases=['selection', 'setting']),
|
|
|
|
question=dict(type='str', aliases=['selection', 'setting']),
|
|
|
|
vtype=dict(type='str', choices=['boolean', 'error', 'multiselect', 'note', 'password', 'seen', 'select', 'string', 'text', 'title']),
|
|
|
|
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),
|
|
|
|
unseen=dict(type='bool', default=False),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
required_together=(['question', 'vtype', 'value'],),
|
|
|
|
required_together=(['question', 'vtype', 'value'],),
|
|
|
@ -217,15 +219,25 @@ def main():
|
|
|
|
if vtype == 'boolean':
|
|
|
|
if vtype == 'boolean':
|
|
|
|
value = to_text(value).lower()
|
|
|
|
value = to_text(value).lower()
|
|
|
|
existing = to_text(prev[question]).lower()
|
|
|
|
existing = to_text(prev[question]).lower()
|
|
|
|
|
|
|
|
elif vtype == 'password':
|
|
|
|
if vtype == 'password':
|
|
|
|
|
|
|
|
existing = get_password_value(module, pkg, question, vtype)
|
|
|
|
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:
|
|
|
|
if value != existing:
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
|
|
if changed:
|
|
|
|
if changed:
|
|
|
|
if not module.check_mode:
|
|
|
|
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)
|
|
|
|
rc, msg, e = set_selection(module, pkg, question, vtype, value, unseen)
|
|
|
|
if rc:
|
|
|
|
if rc:
|
|
|
|
module.fail_json(msg=e)
|
|
|
|
module.fail_json(msg=e)
|
|
|
|