ansible_lint requires private and confirm parameters of vars_prompt to be boolean · Issue #4546 · ansible/ansible-lint · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ansible_lint requires private and confirm parameters of vars_prompt to be boolean and does not allow this rule to be skipped.
ansible accepts a string that it equates to to a Boolean (the error message for an invalid string is The value 'x' is not a valid boolean. Valid booleans include: 'false', 1, 'yes', 't', 0, 'y', 'true', 'f', 'no', '1', 'off', '0', 'on', 'n'
Issue Type
Bug Report
OS / ENVIRONMENT
steve@jabberwock:~/shared$ ansible-lint --versionansible-lint 24 using ansible-core:2.16.14 ansible-compat:24.9.0 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.12
steve@jabberwock:~/shared$ cat ansible_lint_test.yml ---- name: Use variables in vars_prompt private or confirm parameters hosts: localhost vars: need_prompt: "{{ (ansible_run_tags == ['all'] or 'secret' in ansible_run_tags) and 'secret' not in ansible_skip_tags }}" vars_prompt: # noqa: schema[playbook] - name: secret prompt: "{{ 'Enter the required secret' if need_prompt | bool else 'Press Enter to continue' }}" private: "{{ need_prompt }}" confirm: "{{ need_prompt }}" tasks: - name: Test this play meta: noop
Desired Behavior
ansible-lint should not report this as an error but rather, one or more of
Issue a warning that it cannot determine whether the string will resolve to a boolean
Allow the noqa: schema[playbook] to suppress the error/warning
Test this under a different schema that allows it to be skipped
Actual Behavior
steve@jabberwock:~/shared$ ansible-playbook ansible_lint_test.yml
Enter the required secret:
confirm Enter the required secret:
PLAY [Use variables in vars_prompt private or confirm parameters] *************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************
Saturday 08 March 2025 10:25:39 +0000 (0:00:04.444) 0:00:04.444 ********
ok: [localhost]
TASK [Test this play] *********************************************************************************************************************************************************************
Saturday 08 March 2025 10:25:40 +0000 (0:00:00.927) 0:00:05.371 ********
PLAY RECAP ********************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Saturday 08 March 2025 10:25:40 +0000 (0:00:00.000) 0:00:05.372 ********
===============================================================================
Gathering Facts -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.93s
Test this play --------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.00s
steve@jabberwock:~/shared$ ansible-playbook ansible_lint_test.yml --skip-tags secret
Press Enter to continue:
PLAY [Use variables in vars_prompt private or confirm parameters] *************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************
Saturday 08 March 2025 10:25:48 +0000 (0:00:01.413) 0:00:01.413 ********
ok: [localhost]
TASK [Test this play] *********************************************************************************************************************************************************************
Saturday 08 March 2025 10:25:49 +0000 (0:00:00.964) 0:00:02.378 ********
PLAY RECAP ********************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Saturday 08 March 2025 10:25:49 +0000 (0:00:00.000) 0:00:02.378 ********
===============================================================================
Gathering Facts -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.96s
Test this play --------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.00s
steve@jabberwock:~/shared$ ansible-lint ansible_lint_test.yml
WARNING Multiple versions of 'community.dns' were found installed, only the first one will be used, 3.1.2 (/home/steve/.ansible/collections/ansible_collections).
WARNING Multiple versions of 'community.dns' were found installed, only the first one will be used, 3.1.2 (/home/steve/.ansible/collections/ansible_collections).
WARNING Listing 1 violation(s) that are fatal
schema[playbook]: $[0].vars_prompt[0].confirm '{{ need_prompt }}' is not of type 'boolean'
ansible_lint_test.yml:1 Returned errors will not include exact line numbers, but they will mention
the schema name being used as a tag, like ``schema[playbook]``,
``schema[tasks]``.
This rule is not skippable and stops further processing of the file.
If incorrect schema was picked, you might want to either:
* move the file to standard location, so its file is detected correctly.
* use ``kinds:`` option in linter config to help it pick correct file type.
Read documentation for instructions on how to ignore specific rule violations.
Rule Violation Summary
count tag profile rule associated tags
1 schema[playbook] basic core
Failed: 1 failure(s), 0 warning(s) on 1 files. Last profile that met the validation criteria was 'min'.
The text was updated successfully, but these errors were encountered:
Summary
ansible_lint requires private and confirm parameters of
vars_prompt
to be boolean and does not allow this rule to be skipped.ansible accepts a string that it equates to to a Boolean (the error message for an invalid string is
The value 'x' is not a valid boolean. Valid booleans include: 'false', 1, 'yes', 't', 0, 'y', 'true', 'f', 'no', '1', 'off', '0', 'on', 'n'
Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
Desired Behavior
ansible-lint should not report this as an error but rather, one or more of
noqa: schema[playbook]
to suppress the error/warningActual Behavior
The text was updated successfully, but these errors were encountered: