Skip to content
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

ansible-lint not obeying empty-value rule set in .yamllint file #4305

Open
lewisdenny opened this issue Aug 30, 2024 · 0 comments
Open

ansible-lint not obeying empty-value rule set in .yamllint file #4305

lewisdenny opened this issue Aug 30, 2024 · 0 comments
Labels

Comments

@lewisdenny
Copy link

lewisdenny commented Aug 30, 2024

Summary

I would like to enable the yamllint empty-value rule.

I created a .yamllint.yml file with the following content:

rules:
  empty-values:
    forbid-in-block-mappings: true
    forbid-in-flow-mappings: true
    forbid-in-block-sequences: true

When I run ansible-lint --fix my file will have the null value removed, the second run of ansible-lint --fix will fail due to yamllint empty-values rule being enabled. I expect ansible-lint --fix to not remove the null value.

Example change caused by ansible-lint --fix:

$ cat defaults/main.yml
- my_nice_var: null
+ my_nice_var:
Issue Type
  • Bug Report
OS / ENVIRONMENT
$ ansible-lint --version
ansible-lint 24.7.0 using ansible-core:2.16.2 ansible-compat:24.7.0 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
$ cat defaults/main.yml
---
my_nice_var: null

$ cat .yamllint
rules:
  empty-values:
    forbid-in-block-mappings: true
    forbid-in-flow-mappings: true
    forbid-in-block-sequences: true

$ ansible-lint --fix defaults/main.yml

$ cat defaults/main.yml
---
my_nice_var:

$ ansible-lint --fix defaults/main.yml
defaults/main.yml:2: yaml[empty-values]: Empty value in block mapping
Desired Behavior

I expected ansible-lint --fix to not delete the null value from my_nice_var

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Roadmap
Development

No branches or pull requests

2 participants