在saltstack中检查最佳实践的命令行实用程序。
salt-lint的Python项目详细描述
盐绒布
salt-lint检查Salt状态文件(SLS)是否有可能 可能会得到改善
该项目主要基于ansible-lint,它由Will Thames创建,现在作为Ansibleby Red Hat项目的一部分进行维护。
安装
来自源
pip install git+https://github.com/roaldnefs/salt-lint.git
用法
命令行选项
以下是salt-lint--help的输出,提供了基本命令行选项的概述:
Usage: salt-lint [options] init.sls [state ...] Options: --version show program's version number and exit -h, --help show this help message and exit -L list all the rules -t TAGS only check rules whose id/tags match these values -v Increase verbosity level -x SKIP_LIST only check rules whose id/tags do not match these values --nocolor disable colored output --force-color Try force colored output (relying on salt's code) --exclude=EXCLUDE_PATHS path to directories or files to skip. This option is repeatable. -c C Specify configuration file to use. Defaults to ".salt-lint"
Linting Salt状态文件
注意tatsalt-lint接受salt状态文件列表或目录列表是很重要的。
配置
配置文件
Salt lint通过.salt-lint配置文件支持本地配置Salt lint检查工作目录中是否存在此文件,并应用在其中找到的任何配置配置文件位置也可以通过-c path/to/fileCLI标志覆盖
如果在命令行和配置文件中都提供了一个值,那么这些值将被合并(如果像exclude廑path这样的列表),或者在像quiet这样的情况下,首选true值。
预提交设置
要将salt lint与pre-commit一起使用,只需将以下内容添加到本地repo的.pre-commit-config.yaml文件中。在0.12.0版pre-commit之前,文件是hooks.yaml(现在是.pre-commit-config.yaml)。
---# For use with pre-commit.# See usage instructions at http://pre-commit.com-id:salt-lintname:Salt-lintdescription:This hook runs salt-lint.entry:salt-lintlanguage:pythonfiles:\.(sls)$