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 incompatible with yamllint max line-length #4235

Closed
1 task done
ddeepwell opened this issue Jun 24, 2024 · 3 comments
Closed
1 task done

Ansible lint incompatible with yamllint max line-length #4235

ddeepwell opened this issue Jun 24, 2024 · 3 comments
Labels

Comments

@ddeepwell
Copy link

Summary

ansible-lint --fix does not respect the maximum yaml line length in a repo where the line length is specified in a .yamllint file and multi-line strings use double quotes with a \ to wrap onto the next line.

When running ansible-lint --fix twice, the double quotes and line split are removed on the first pass, followed by a line-length error on the second pass.

Issue Type

Bug Report

Component Name

lint

Ansible Version

$ ansible --version
ansible [core 2.17.1]
  config file = None
  configured module search path = ['/Users/me/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /private/tmp/ansible-test/.venv/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/me/.ansible/collections:/usr/share/ansible/collections
  executable location = /private/tmp/ansible-test/.venv/bin/ansible
  python version = 3.11.9 (main, Apr  2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)] (/private/tmp/ansible-test/.venv/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all

OS / Environment

MacOS Sonoma 14.5

Steps to Reproduce

A minimum test repo contains two files:

  1. .yamllint file:
---
rules:
  line-length:
    max: 88

and 2) a roles/arole/tasks/main.yml file:

---
- name: Download tarball
  ansible.builtin.get_url:
    url: "https://download.samba.org/pub/application/src/\
      application-application.version.tar.gz"
    dest: /tmp/app.tar.gz
    mode: "644"

Then run ansible-lint --fix twice.

Expected Results

I expected the multi-line string to be ignored since the fix would have broken the max line length limit.

Actual Results

ERROR    Rule specific fix not applied for: yaml/yaml roles/arole/tasks/main.yml:4
WARNING  Listing 1 violation(s) that are fatal
yaml[line-length]: Line too long (94 > 88 characters)
roles/arole/tasks/main.yml:4

Read documentation for instructions on how to ignore specific rule violations.

                Rule Violation Summary                
 count tag               profile rule associated tags 
     1 yaml[line-length] basic   formatting, yaml     

Failed: 1 failure(s), 0 warning(s) on 4 files. Last profile that met the validation criteria was 'min'.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added the bug label Jun 24, 2024
@ansibot
Copy link

ansibot commented Jun 24, 2024

Files identified in the description:

None

If these files are incorrect, please update the component name section of the description or use the component bot command.

@ddeepwell
Copy link
Author

Whoops. Just noticed this would be better served in the https://github.com/ansible/ansible-lint repo. I'm not sure how to move it there.

@mattclay mattclay transferred this issue from ansible/ansible Jun 27, 2024
@ddeepwell
Copy link
Author

The issue was duplicated at #4233.

@ddeepwell ddeepwell reopened this Jul 2, 2024
@ddeepwell ddeepwell closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants