diff --git a/changelogs/fragments/58965-npm-validate-option-types.yml b/changelogs/fragments/58965-npm-validate-option-types.yml new file mode 100644 index 00000000000..1e1aef58812 --- /dev/null +++ b/changelogs/fragments/58965-npm-validate-option-types.yml @@ -0,0 +1,2 @@ +bugfixes: + - "npm - Validate that all passed options have proper types." diff --git a/lib/ansible/modules/packaging/language/npm.py b/lib/ansible/modules/packaging/language/npm.py index 4afa2ef56e6..f89ceee6afd 100644 --- a/lib/ansible/modules/packaging/language/npm.py +++ b/lib/ansible/modules/packaging/language/npm.py @@ -26,14 +26,17 @@ options: name: description: - The name of a node.js library to install + type: str required: false path: description: - The base path where to install the node.js libraries + type: path required: false version: description: - The version to be installed + type: str required: false global: description: @@ -45,6 +48,7 @@ options: description: - The executable location for npm. - This is useful if you are using a version manager, such as nvm + type: path required: false ignore_scripts: description: @@ -75,11 +79,13 @@ options: description: - The registry to install modules from. required: false + type: str version_added: "1.6" state: description: - The state of the node.js library required: false + type: str default: present choices: [ "present", "absent", "latest" ] requirements: @@ -241,12 +247,12 @@ class Npm(object): def main(): arg_spec = dict( - name=dict(default=None), + name=dict(default=None, type='str'), path=dict(default=None, type='path'), - version=dict(default=None), + version=dict(default=None, type='str'), production=dict(default='no', type='bool'), executable=dict(default=None, type='path'), - registry=dict(default=None), + registry=dict(default=None, type='str'), state=dict(default='present', choices=['present', 'absent', 'latest']), ignore_scripts=dict(default=False, type='bool'), unsafe_perm=dict(default=False, type='bool'), diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index 246160ed448..edca52d0503 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -3025,8 +3025,6 @@ lib/ansible/modules/packaging/language/gem.py E337 lib/ansible/modules/packaging/language/maven_artifact.py E324 lib/ansible/modules/packaging/language/maven_artifact.py E337 lib/ansible/modules/packaging/language/maven_artifact.py E338 -lib/ansible/modules/packaging/language/npm.py E337 -lib/ansible/modules/packaging/language/npm.py E338 lib/ansible/modules/packaging/language/pear.py E322 lib/ansible/modules/packaging/language/pear.py E326 lib/ansible/modules/packaging/language/pear.py E337