The implicit default for type=bool options is not 'false', but 'none' (#72699)

* The implicit default for type=bool options is not 'false', but 'none'.

* Fix modules, resp. add ignore.txt entries.
pull/45198/head
Felix Fontein 4 years ago committed by GitHub
parent f94ba68d8f
commit 5226ac5778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- "ansible-test validate-modules - no longer assume that ``default`` for ``type=bool`` options is ``false``, as the default is ``none`` and for some modules, ``none`` and ``false`` mean different things (https://github.com/ansible/ansible/issues/69561)."

@ -36,9 +36,9 @@ options:
update_cache: update_cache:
description: description:
- Run the equivalent of C(apt-get update) before the operation. Can be run as part of the package installation or as a separate step. - Run the equivalent of C(apt-get update) before the operation. Can be run as part of the package installation or as a separate step.
- Default is not to update the cache.
aliases: [ update-cache ] aliases: [ update-cache ]
type: bool type: bool
default: 'no'
update_cache_retries: update_cache_retries:
description: description:
- Amount of retries if the cache update fails. Also see I(update_cache_retry_max_delay). - Amount of retries if the cache update fails. Also see I(update_cache_retry_max_delay).

@ -123,7 +123,7 @@ options:
- New variables are added on top of crontab. - New variables are added on top of crontab.
- I(name) and I(value) parameters are the name and the value of environment variable. - I(name) and I(value) parameters are the name and the value of environment variable.
type: bool type: bool
default: no default: false
version_added: "2.1" version_added: "2.1"
insertafter: insertafter:
description: description:
@ -576,7 +576,7 @@ def main():
reboot=dict(type='bool', default=False), reboot=dict(type='bool', default=False),
special_time=dict(type='str', choices=["reboot", "yearly", "annually", "monthly", "weekly", "daily", "hourly"]), special_time=dict(type='str', choices=["reboot", "yearly", "annually", "monthly", "weekly", "daily", "hourly"]),
disabled=dict(type='bool', default=False), disabled=dict(type='bool', default=False),
env=dict(type='bool'), env=dict(type='bool', default=False),
insertafter=dict(type='str'), insertafter=dict(type='str'),
insertbefore=dict(type='str'), insertbefore=dict(type='str'),
), ),

@ -55,7 +55,7 @@ options:
description: description:
- Do not set 'seen' flag when pre-seeding. - Do not set 'seen' flag when pre-seeding.
type: bool type: bool
default: no default: false
author: author:
- Brian Coca (@bcoca) - Brian Coca (@bcoca)
''' '''
@ -140,7 +140,7 @@ def main():
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='str', aliases=['answer']),
unseen=dict(type='bool'), unseen=dict(type='bool', default=False),
), ),
required_together=(['question', 'vtype', 'value'],), required_together=(['question', 'vtype', 'value'],),
supports_check_mode=True, supports_check_mode=True,

@ -449,7 +449,7 @@ def main():
argument_spec.update( argument_spec.update(
url=dict(type='str', required=True), url=dict(type='str', required=True),
dest=dict(type='path', required=True), dest=dict(type='path', required=True),
backup=dict(type='bool'), backup=dict(type='bool', default=False),
sha256sum=dict(type='str', default=''), sha256sum=dict(type='str', default=''),
checksum=dict(type='str', default=''), checksum=dict(type='str', default=''),
timeout=dict(type='int', default=10), timeout=dict(type='int', default=10),

@ -326,6 +326,7 @@ options:
- If no chain is specified then the entire table is purged. - If no chain is specified then the entire table is purged.
- Ignores all other parameters. - Ignores all other parameters.
type: bool type: bool
default: false
version_added: "2.2" version_added: "2.2"
policy: policy:
description: description:

@ -1734,8 +1734,6 @@ class ModuleValidator(Validator):
msg=msg msg=msg
) )
continue continue
elif data.get('default') is None and _type == 'bool' and 'options' not in data:
arg_default = False
doc_options_args = [] doc_options_args = []
for alias in sorted(set([arg] + list(aliases))): for alias in sorted(set([arg] + list(aliases))):
@ -1765,8 +1763,6 @@ class ModuleValidator(Validator):
if 'default' in doc_options_arg and not is_empty(doc_options_arg['default']): if 'default' in doc_options_arg and not is_empty(doc_options_arg['default']):
with CaptureStd(): with CaptureStd():
doc_default = _type_checker(doc_options_arg['default']) doc_default = _type_checker(doc_options_arg['default'])
elif doc_options_arg.get('default') is None and _type == 'bool' and 'suboptions' not in doc_options_arg:
doc_default = False
except (Exception, SystemExit): except (Exception, SystemExit):
msg = "Argument '%s' in documentation" % arg msg = "Argument '%s' in documentation" % arg
if context: if context:

@ -85,6 +85,7 @@ lib/ansible/modules/async_wrapper.py pylint:ansible-bad-function # ignore, requi
lib/ansible/modules/async_wrapper.py use-argspec-type-path lib/ansible/modules/async_wrapper.py use-argspec-type-path
lib/ansible/modules/blockinfile.py validate-modules:doc-choices-do-not-match-spec lib/ansible/modules/blockinfile.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/blockinfile.py validate-modules:doc-default-does-not-match-spec lib/ansible/modules/blockinfile.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/command.py validate-modules:doc-default-does-not-match-spec # _uses_shell is undocumented
lib/ansible/modules/command.py validate-modules:doc-missing-type lib/ansible/modules/command.py validate-modules:doc-missing-type
lib/ansible/modules/command.py validate-modules:nonexistent-parameter-documented lib/ansible/modules/command.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/command.py validate-modules:undocumented-parameter lib/ansible/modules/command.py validate-modules:undocumented-parameter
@ -112,6 +113,7 @@ lib/ansible/modules/pip.py validate-modules:invalid-ansiblemodule-schema
lib/ansible/modules/replace.py validate-modules:nonexistent-parameter-documented lib/ansible/modules/replace.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/service.py validate-modules:nonexistent-parameter-documented lib/ansible/modules/service.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/service.py validate-modules:use-run-command-not-popen lib/ansible/modules/service.py validate-modules:use-run-command-not-popen
lib/ansible/modules/stat.py validate-modules:doc-default-does-not-match-spec # get_md5 is undocumented
lib/ansible/modules/stat.py validate-modules:parameter-invalid lib/ansible/modules/stat.py validate-modules:parameter-invalid
lib/ansible/modules/stat.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/stat.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/stat.py validate-modules:undocumented-parameter lib/ansible/modules/stat.py validate-modules:undocumented-parameter

Loading…
Cancel
Save