← 返回命令列表

Linux command

ansible-lint 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Lint

ansible-lint [playbook.yml]

Example

ansible-lint

Example

ansible-lint -p [production] [playbook.yml]

List

ansible-lint -L

Skip

ansible-lint --skip-list [yaml,risky-shell-pipe] [playbook.yml]

Example

ansible-lint -f json [playbook.yml]

说明

ansible-lint checks Ansible playbooks, roles, and collections for practices and behaviors that could potentially be improved. It identifies deprecated syntax, security concerns, style issues, and best practice violations. The tool helps maintain consistent, high-quality Ansible code and catch common mistakes before deployment.

参数

-L, --list-rules
List all available rules
-x _rules_, --skip-list _rules_
Skip specific rules
-w _rules_, --warn-list _rules_
Treat rules as warnings only
-p _profile_, --profile _profile_
Select rule profile (min, basic, moderate, safety, shared, production)
-f _format_, --format _format_
Output format: rich, plain, json, codeclimate, sarif
--fix
Attempt to fix linting errors
-q, --quiet
Quieter output
--strict
Treat warnings as errors
-c _file_, --config-file _file_
Configuration file

FAQ

What is the ansible-lint command used for?

ansible-lint checks Ansible playbooks, roles, and collections for practices and behaviors that could potentially be improved. It identifies deprecated syntax, security concerns, style issues, and best practice violations. The tool helps maintain consistent, high-quality Ansible code and catch common mistakes before deployment.

How do I run a basic ansible-lint example?

Run `ansible-lint [playbook.yml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -L, --list-rules do in ansible-lint?

List all available rules