mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
hopefully last batch of fixes
- removed previous 'typification' of input as it needs it is typed by module as strings and needs to be output as strings, making it useless. - now checks for vtype and value against None when question is specified - simplified set_selections as vtype and value should have a string value going in. - added example of querying questions for a package - added module requirement of question,vtype and value being required together.
This commit is contained in:
parent
a1de284dba
commit
f475de2316
1 changed files with 10 additions and 15 deletions
|
@ -26,7 +26,8 @@ DOCUMENTATION = '''
|
||||||
module: debconf
|
module: debconf
|
||||||
short_description: Configure a .deb package
|
short_description: Configure a .deb package
|
||||||
description:
|
description:
|
||||||
- Configure a .deb package using debconf-set-selections.
|
- Configure a .deb package using debconf-set-selections. Or just query
|
||||||
|
existing selections.
|
||||||
version_added: "1.5"
|
version_added: "1.5"
|
||||||
notes:
|
notes:
|
||||||
- This module requires the command line debconf tools.
|
- This module requires the command line debconf tools.
|
||||||
|
@ -78,6 +79,9 @@ debconf: name=locales question='locales/locales_to_be_generated value='en_US.UT
|
||||||
|
|
||||||
# Accept oracle license
|
# Accept oracle license
|
||||||
debconf: name='oracle-java7-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'
|
debconf: name='oracle-java7-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'
|
||||||
|
|
||||||
|
# Specifying package you can register/return the list of questions and current values
|
||||||
|
debconf: name='tzdata'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def get_selections(module, pkg):
|
def get_selections(module, pkg):
|
||||||
|
@ -98,14 +102,7 @@ def get_selections(module, pkg):
|
||||||
|
|
||||||
def set_selection(module, pkg, question, vtype, value, unseen):
|
def set_selection(module, pkg, question, vtype, value, unseen):
|
||||||
|
|
||||||
answer = [ question ]
|
data = ' '.join([ question, vtype, value ])
|
||||||
if 'vtype':
|
|
||||||
answer.append(vtype)
|
|
||||||
|
|
||||||
if value is None:
|
|
||||||
value = ''
|
|
||||||
answer.append(value)
|
|
||||||
data = ' '.join(answer)
|
|
||||||
|
|
||||||
setsel = module.get_bin_path('debconf-set-selections', True)
|
setsel = module.get_bin_path('debconf-set-selections', True)
|
||||||
cmd = ["echo '%s %s' |" % (pkg, data), setsel]
|
cmd = ["echo '%s %s' |" % (pkg, data), setsel]
|
||||||
|
@ -124,6 +121,7 @@ def main():
|
||||||
value= dict(required=False, type='str'),
|
value= dict(required=False, type='str'),
|
||||||
unseen = dict(required=False, type='bool'),
|
unseen = dict(required=False, type='bool'),
|
||||||
),
|
),
|
||||||
|
required_together = ( ['question','vtype', 'value'],),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -140,13 +138,10 @@ def main():
|
||||||
changed = False
|
changed = False
|
||||||
msg = ""
|
msg = ""
|
||||||
|
|
||||||
# Adjust value field if needed
|
|
||||||
if vtype == 'boolean':
|
|
||||||
value = boolean(value)
|
|
||||||
elif vtype == 'multiselect' and (isisntance(value, list) or isinstace(value, set)):
|
|
||||||
value = ','.join(value)
|
|
||||||
|
|
||||||
if question is not None:
|
if question is not None:
|
||||||
|
if vtype is None or value is None:
|
||||||
|
module.fail_json(msg="when supliying a question you must supply a valide vtype and value")
|
||||||
|
|
||||||
if not question in prev or prev[question] != value:
|
if not question in prev or prev[question] != value:
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue