# Custom module parameter type checking ignored on linting

**URL:** <https://forum.ansible.com/t/custom-module-parameter-type-checking-ignored-on-linting/10174>\
**Category:** Get Help\
**Tags:** module, ansible-lint\
**Created:** [October 11, 2024, 2:02am UTC](https://forum.ansible.com/t/custom-module-parameter-type-checking-ignored-on-linting/10174 "2024-10-11T02:02:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [October 11, 2024, 2:02am UTC](https://forum.ansible.com/t/custom-module-parameter-type-checking-ignored-on-linting/10174/1 "2024-10-11T02:02:04Z")

</div>

I’ve got an custom module I’m tweaking. It works, but “`ansible-lint -vv`” is throwing these messages that I’m trying to understand. I’d really appreciate any help with this.

The `ansible-lint` I’m running is

```txt
$ ansible-lint --version
ansible-lint 24.9.2 using ansible-core:2.16.9 ansible-compat:24.9.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8

```

Here are the two message in question.

```txt
DEBUG Type checking ignored for 'symlink' option in task 'mwsdinstall.py' at line 23.
DEBUG Type checking ignored for 'symlink' option in task 'mwsdinstall.py' at line 71.

```

Both invocations of that module look like this:

```yaml
- name: "Invoke mwsdinstall: state: {{ mw_common_sdinstall_state }}; package: {{ mw_common_sdinstall_name }}; version {{ mw_common_sdinstall_version }}" # noqa name[template]
  mwsdinstall.py:
    state: "{{ mw_common_sdinstall_state }}" # noqa yaml[colons] jinja[spacing]
    name: "{{ mw_common_sdinstall_name }}" # noqa yaml[colons]
    version: "{{ mw_common_sdinstall_version }}" # noqa yaml[colons]
    symlink: "{{ mw_common_sdinstall_symlink }}" # noqa yaml[colons]
    symlink_names: "{{[mw_common_sdinstall_symlink_names] | flatten }}" # noqa yaml[colons]
    user: "{{ mw_common_sdinstall_user }}" # noqa yaml[colons]
    group: "{{ mw_common_sdinstall_group }}" # noqa yaml[colons]
    appbase: "{{ mw_common_sdinstall_appbase }}" # noqa yaml[colons]
    repobase: "{{ mw_common_sdinstall_repobase }}" # noqa yaml[colons]
    pkgage: "{{ mw_common_sdinstall_pkgage }}" # noqa yaml[colons]
    fallbacks: "{{ mw_common_sdinstall_fallbacks }}" # noqa yaml[colons]
  register: mw_common_sdinstall

```

`{{ mw_common_sdinstall_symlink }}"` is defined in the `defaults/main.yml` for this role:

```yaml
---
# ./defaults/main.yml
mw_common_sdinstall_state: present # noqa yaml[colons]
mw_common_sdinstall_symlink: true # noqa yaml[colons]
mw_common_sdinstall_symlink_names: ['latest'] # noqa yaml[colons]
mw_common_sdinstall_user: "{{ mw_global_ci_usr }}" # noqa yaml[colons]
mw_common_sdinstall_group: "{{ mw_global_ci_grp }}" # noqa yaml[colons]
mw_common_sdinstall_appbase: "{{ mw_global_appbase }}" # noqa yaml[colons]
mw_common_sdinstall_repobase: "{{ mw_global_repobase }}" # noqa yaml[colons]
mw_common_sdinstall_pkgage: .pkg_age # noqa yaml[colons]
mw_common_sdinstall_fallbacks: 3 # noqa yaml[colons]

```

In the `mwsdinstall.py` module itself, the argspec looks like this:

```py
def main():
    fields = {
        "name": {"type": "str", "required": True},
        "version": {"type": "str", "required": True},
        "symlink": {"type": "bool", "default": True},
        "symlink_names": {"type": "list", "default": ["cur", "-latest"], "elements": "str"},
        "user": {"type": "str", "default": "jenkinsci"},
        "group": {"type": "str", "default": "middleware"},
        "pkgage": {"type": "str", "default": ".pkg_age"},
        "fallbacks": {"type": "int", "required": False},
        "appbase": {"type": "str", "default": "/opt/local"},
        "repobase": {"type": "str", "default": "/middleware/software-deploy"},
        "state": {"type": "str", "default": "present", "choices": ["present", "absent", "check"]},
    }

    module = AnsibleModule(argument_spec=fields, supports_check_mode=True)

```

I notice that `symlink` is the only `bool` in my parameters. Is this normal behavior for `ansible-lint`, or is something more subtle going on? I’m really stumped.

Thanks.

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [October 14, 2024, 3:44pm UTC](https://forum.ansible.com/t/custom-module-parameter-type-checking-ignored-on-linting/10174/2 "2024-10-14T15:44:12Z")

</div>

I was curious so I played around with this and found that `ansible-lint` will show that message in the debug logs if the value cannot be parsed as the expected type _and_ contains jinja template markers `{{ }}`. If the value does not contain jinja markers, a warning is shown.

So in your case, its unable to parse `{{ var }}` as a bool. It doesnt actually try to substitute `var` in, so yea that makes sense.

As for why its just the `bool` parameter…its not! `ansible-lint` just quits after it finds one attribute it cant parse. So if you remove that boolean attribute from your module, it should show a similar log message for the next `int` variable (or maybe the `list` var, i didnt test with lists)

Heres the ansible-lint code that handles the parsing error. [ansible-lint/src/ansiblelint/rules/args.py at a3f8492505b60d4be2c9df973967dca436c0cfa4 · ansible/ansible-lint · GitHub](https://github.com/ansible/ansible-lint/blob/a3f8492505b60d4be2c9df973967dca436c0cfa4/src/ansiblelint/rules/args.py#L232-L243)

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [October 14, 2024, 4:02pm UTC](https://forum.ansible.com/t/custom-module-parameter-type-checking-ignored-on-linting/10174/3 "2024-10-14T16:02:05Z")

</div>

👀 Wow. Thanks so much for digging into this. 🧭

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 13, 2024, 4:02pm UTC](https://forum.ansible.com/t/custom-module-parameter-type-checking-ignored-on-linting/10174/4 "2024-11-13T16:02:36Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
