A command-line utility that checks for best practices in SaltStack.
Project description
Salt-lint
salt-lint checks Salt state files (SLS) for practices and behavior that could potentially be improved.
The project is heavily based on ansible-lint, which was created by Will Thames and is now maintained as part of the Ansible by Red Hat project.
Installing
Using Pip
pip install salt-lint
From Source
pip install git+https://github.com/roaldnefs/salt-lint.git
Usage
Command Line Options
The following is the output from salt-lint --help, providing an overview of the basic command line options:
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 state files
It’s important to note tat salt-lint accepts a list of Salt state files or a list of directories.
Configuring
Configuration File
Salt-lint supports local configuration via a .salt-lint configuration file. Salt-lint check the working directory for the presence of this file and applies any configuration found there. The configuration file location can also be overridden via the -c path/to/file CLI flag.
If a value is provided on both the command line and via a configuration file, the values will be merged (if a list like exclude_paths), or the True value will be preferred, in the case of something like quiet.
Pre-commit Setup
To use salt-lint with pre-commit, just add the following to your local repo’s .pre-commit-config.yaml file. Prior to version 0.12.0 of pre-commit the file was hooks.yaml (now .pre-commit-config.yaml).
---
# For use with pre-commit.
# See usage instructions at http://pre-commit.com
- id: salt-lint
name: Salt-lint
description: This hook runs salt-lint.
entry: salt-lint
language: python
files: \.(sls)$
Rules
False Positives: Skipping Rules
Some rules are bit of a rule of thumb. To skip a specific rule for a specific task, inside your state add # noqa [rule_id] at the end of the line. You can skip multiple rules via a space-separated list. Example:
/tmp/testfile:
file.managed:
- source: salt://{{unspaced_var}}/example # noqa: 206
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file salt-lint-0.0.4.tar.gz
.
File metadata
- Download URL: salt-lint-0.0.4.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3e81454f15bbdb662ec92c6276add5b6782b315550ada885fc9026aad820261 |
|
MD5 | 0a8f0746ce60667a527d23033b1d16c2 |
|
BLAKE2b-256 | 7b4f300ce80d5b3e696297359fae5dac5dea1855810ba0c260a53a58f3f76c6b |