Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ansible/ansible.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fontein <felix@fontein.de>2022-11-01 18:12:59 +0300
committerGitHub <noreply@github.com>2022-11-01 18:12:59 +0300
commit6e379e5d656089cdd4bc35c30c5911669e8d59eb (patch)
treea199077bc1d096077a4f3cc590542e8aefa49cc0
parent6674c43edd203d1241507c4d857f555a7c844c18 (diff)
validate-modules: do not treat falsy non-`False` defaults as `None` (#79267)
* Do not treat falsy non-False defaults as None. * Fix various instances of this in modules. * Add changelog fragment.
-rw-r--r--changelogs/fragments/79267-validate-modules-defaults.yml2
-rw-r--r--lib/ansible/modules/dnf.py7
-rw-r--r--lib/ansible/modules/getent.py1
-rw-r--r--lib/ansible/modules/iptables.py2
-rw-r--r--lib/ansible/modules/replace.py1
-rw-r--r--lib/ansible/modules/service.py1
-rw-r--r--lib/ansible/modules/unarchive.py2
-rw-r--r--lib/ansible/modules/uri.py1
-rw-r--r--lib/ansible/modules/yum.py6
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py6
-rw-r--r--test/sanity/ignore.txt1
11 files changed, 22 insertions, 8 deletions
diff --git a/changelogs/fragments/79267-validate-modules-defaults.yml b/changelogs/fragments/79267-validate-modules-defaults.yml
new file mode 100644
index 00000000000..819626b9c4d
--- /dev/null
+++ b/changelogs/fragments/79267-validate-modules-defaults.yml
@@ -0,0 +1,2 @@
+minor_changes:
+ - "ansible-test validate-modules - no longer treat falsy non-``False`` values for defaults as ``None`` (https://github.com/ansible/ansible/pull/79267)."
diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py
index ce8c5ea1776..62d1e69d048 100644
--- a/lib/ansible/modules/dnf.py
+++ b/lib/ansible/modules/dnf.py
@@ -28,11 +28,11 @@ options:
Spaces around the operator are required.
- You can also pass an absolute path for a binary which is provided by the package to install.
See examples for more information.
- required: true
aliases:
- pkg
type: list
elements: str
+ default: []
list:
description:
@@ -55,6 +55,7 @@ options:
When specifying multiple repos, separate them with a ",".
type: list
elements: str
+ default: []
disablerepo:
description:
@@ -63,6 +64,7 @@ options:
When specifying multiple repos, separate them with a ",".
type: list
elements: str
+ default: []
conf_file:
description:
@@ -108,6 +110,7 @@ options:
version_added: "2.7"
type: list
elements: str
+ default: []
skip_broken:
description:
- Skip all unavailable packages or packages with broken dependencies
@@ -151,12 +154,14 @@ options:
version_added: "2.7"
type: list
elements: str
+ default: []
disable_plugin:
description:
- I(Plugin) name to disable for the install/update operation.
The disabled plugins will not persist beyond the transaction.
version_added: "2.7"
type: list
+ default: []
elements: str
disable_excludes:
description:
diff --git a/lib/ansible/modules/getent.py b/lib/ansible/modules/getent.py
index fdfcf43bf23..dbe87b92cb7 100644
--- a/lib/ansible/modules/getent.py
+++ b/lib/ansible/modules/getent.py
@@ -27,7 +27,6 @@ options:
- Key from which to return values from the specified database, otherwise the
full contents are returned.
type: str
- default: ''
service:
description:
- Override all databases with the specified service
diff --git a/lib/ansible/modules/iptables.py b/lib/ansible/modules/iptables.py
index c0fdc3ff8c5..34d8df9c824 100644
--- a/lib/ansible/modules/iptables.py
+++ b/lib/ansible/modules/iptables.py
@@ -118,7 +118,6 @@ options:
- TCP flags specification.
- C(tcp_flags) expects a dict with the two keys C(flags) and C(flags_set).
type: dict
- default: {}
version_added: "2.4"
suboptions:
flags:
@@ -233,6 +232,7 @@ options:
- It can only be used in conjunction with the protocols tcp, udp, udplite, dccp and sctp.
type: list
elements: str
+ default: []
version_added: "2.11"
to_ports:
description:
diff --git a/lib/ansible/modules/replace.py b/lib/ansible/modules/replace.py
index 4b8f74f5620..d8b192663df 100644
--- a/lib/ansible/modules/replace.py
+++ b/lib/ansible/modules/replace.py
@@ -67,6 +67,7 @@ options:
- If not set, matches are removed entirely.
- Backreferences can be used ambiguously like C(\1), or explicitly like C(\g<1>).
type: str
+ default: ''
after:
description:
- If specified, only content after this match will be replaced/removed.
diff --git a/lib/ansible/modules/service.py b/lib/ansible/modules/service.py
index a84829c90e4..69737e020cf 100644
--- a/lib/ansible/modules/service.py
+++ b/lib/ansible/modules/service.py
@@ -76,6 +76,7 @@ options:
- Additional arguments provided on the command line.
- While using remote hosts with systemd this setting will be ignored.
type: str
+ default: ''
aliases: [ args ]
use:
description:
diff --git a/lib/ansible/modules/unarchive.py b/lib/ansible/modules/unarchive.py
index 69e769d05d0..b6fe147c248 100644
--- a/lib/ansible/modules/unarchive.py
+++ b/lib/ansible/modules/unarchive.py
@@ -92,7 +92,7 @@ options:
- Command-line options with multiple elements must use multiple lines in the array, one for each element.
type: list
elements: str
- default: ""
+ default: []
version_added: "2.1"
remote_src:
description:
diff --git a/lib/ansible/modules/uri.py b/lib/ansible/modules/uri.py
index e67f90a466f..c6c06dd2ad7 100644
--- a/lib/ansible/modules/uri.py
+++ b/lib/ansible/modules/uri.py
@@ -135,6 +135,7 @@ options:
of C(2.3) supplying C(Content-Type) here will override the header
generated by supplying C(json) or C(form-urlencoded) for I(body_format).
type: dict
+ default: {}
version_added: '2.1'
validate_certs:
description:
diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py
index cce8f4cb755..23b18076678 100644
--- a/lib/ansible/modules/yum.py
+++ b/lib/ansible/modules/yum.py
@@ -41,11 +41,13 @@ options:
aliases: [ pkg ]
type: list
elements: str
+ default: []
exclude:
description:
- Package name(s) to exclude when state=present, or latest
type: list
elements: str
+ default: []
version_added: "2.0"
list:
description:
@@ -72,6 +74,7 @@ options:
separated string
type: list
elements: str
+ default: []
version_added: "0.9"
disablerepo:
description:
@@ -82,6 +85,7 @@ options:
separated string
type: list
elements: str
+ default: []
version_added: "0.9"
conf_file:
description:
@@ -171,6 +175,7 @@ options:
The enabled plugin will not persist beyond the transaction.
type: list
elements: str
+ default: []
version_added: "2.5"
disable_plugin:
description:
@@ -178,6 +183,7 @@ options:
The disabled plugins will not persist beyond the transaction.
type: list
elements: str
+ default: []
version_added: "2.5"
releasever:
description:
diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py
index 9513ed30b12..ce440bca1f3 100644
--- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py
+++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py
@@ -79,7 +79,7 @@ from .module_args import AnsibleModuleImportError, AnsibleModuleNotInitialized,
from .schema import ansible_module_kwargs_schema, doc_schema, return_schema
-from .utils import CaptureStd, NoArgsAnsibleModule, compare_unordered_lists, is_empty, parse_yaml, parse_isodate
+from .utils import CaptureStd, NoArgsAnsibleModule, compare_unordered_lists, parse_yaml, parse_isodate
if PY3:
@@ -1789,7 +1789,7 @@ class ModuleValidator(Validator):
)
arg_default = None
- if 'default' in data and not is_empty(data['default']):
+ if 'default' in data and data['default'] is not None:
try:
with CaptureStd():
arg_default = _type_checker(data['default'])
@@ -1830,7 +1830,7 @@ class ModuleValidator(Validator):
try:
doc_default = None
- if 'default' in doc_options_arg and not is_empty(doc_options_arg['default']):
+ if 'default' in doc_options_arg and doc_options_arg['default'] is not None:
with CaptureStd():
doc_default = _type_checker(doc_options_arg['default'])
except (Exception, SystemExit):
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index e9ea871d82f..adebe5f972f 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -30,7 +30,6 @@ lib/ansible/modules/copy.py pylint:disallowed-name
lib/ansible/modules/copy.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/copy.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/copy.py validate-modules:undocumented-parameter
-lib/ansible/modules/dnf.py validate-modules:doc-required-mismatch
lib/ansible/modules/dnf.py validate-modules:parameter-invalid
lib/ansible/modules/file.py validate-modules:undocumented-parameter
lib/ansible/modules/find.py use-argspec-type-path # fix needed