ansible-lint "yaml[line-length]" violation in CI
ansible-lint embeds yamllint. The yaml[line-length] rule fires when a line is longer than the configured limit (default 160). It is a formatting violation that fails the lint step under strict profiles.
What this error means
ansible-lint reports "yaml[line-length]: Line too long (NNN > 160 characters)" pointing at a specific file and line.
yaml[line-length]: Line too long (182 > 160 characters)
roles/webserver/tasks/main.yml:24Common causes
A line exceeds the yamllint limit
A long command, a big inline dict, or a long templated string pushes the line past the configured maximum.
The default limit is stricter than intended
The project has no yamllint config, so the default line-length applies more strictly than the team wants.
How to fix it
Wrap the long line
Use YAML folding or block scalars, or split a long dict across lines.
- name: Run a long command
ansible.builtin.command: >
/usr/bin/tool --flag-one value-one
--flag-two value-two --flag-three value-threeAdjust the line-length rule
Set a project line-length in yamllint config if the default is too strict, rather than disabling the rule everywhere.
# .yamllint
rules:
line-length:
max: 200
level: warningHow to prevent it
- Wrap long commands with folded scalars.
- Set a project yamllint config with an agreed line length.
- Run ansible-lint locally so formatting fixes land before CI.