8000 ansible_lint requires private and confirm parameters of vars_prompt to be boolean · Issue #4546 · ansible/ansible-lint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ansible_lint requires private and confirm parameters of vars_prompt to be boolean #4546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tsgsh opened this issue Mar 8, 2025 · 0 comments
Labels

Comments

@tsgsh
Copy link
tsgsh commented Mar 8, 2025
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
  • Bug Report
OS / ENVIRONMENT
steve@jabberwock:~/shared$ ansible-lint --version
ansible-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$ which ansible ansible-lint yamllint
/usr/bin/ansible
/usr/bin/ansible-lint
/usr/bin/yamllint
steve@jabberwock:~/shared$ dnf list ansible python3-ansible-lint yamllint
Updating and loading repositories:
Repositories loaded.
Installed packages
ansible.noarch              9.13.0-1.fc41   updates
python3-ansible-lint.noarch 1:24.7.0-2.fc41 <unknown>
yamllint.noarch             1.35.1-3.fc41   <unknown>
STEPS TO REPRODUCE
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'.
@tsgsh tsgsh added bug new Triage required labels Mar 8, 2025
@audgirka audgirka removed the new Triage required label Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
384F
Development

No branches or pull requests

2 participants
0