Registry / devops / salt-lint

salt-lint

JSON →
library0.9.2pypypiunverified

Salt-lint is a command-line utility that checks Salt State files (SLS) for best practices and potential improvements in SaltStack environments. Heavily inspired by `ansible-lint`, it helps enforce coding standards and identify common pitfalls in Salt configurations. It is currently at version 0.9.2 and maintains an active release cadence, with multiple bugfix and feature releases per year.

pip install salt-lint
INSTALL
IMPORT
SIG · SALT-LINT
S
salt-lint
devopspythonv0.9.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Salt-lint is primarily a command-line tool. Create a sample SaltStack state file (e.g., `my_salt_states/init.sls`) and then run `salt-lint` against it. The output will show any detected issues or warnings.

mkdir -p my_salt_states echo 'my_package: pkg.installed: - name: vim - version: latest - onchanges: - file: /etc/vimrc my_service: service.running: - name: apache2 - enable: True - watch: - pkg: my_package' > my_salt_states/init.sls salt-lint my_salt_states/init.sls
salt-lint --version
Debug
Known issues
breakingPython 2.7 support was officially dropped in version 0.6.0. Users on older Python environments must upgrade to Python 3.6 or newer to use current versions of salt-lint.
fix
Upgrade your Python environment to version 3.6 or higher.
affects: >=0.6.0
gotchaNew linting rules are frequently added, and existing rules may be modified or removed, which can lead to changes in linting output and new errors appearing after an upgrade. For example, rule 218 was removed in v0.6.1, and rule 210 was reverted in v0.9.1.
fix
Review the changelog (e.g., on GitHub or ReadTheDocs) before upgrading to understand changes in linting rules. Consider pinning to minor versions if strict output stability is required.
affects: All versions
gotchaSLS files with periods in their name (other than the `.sls` suffix) are not correctly referenced by Salt. Salt-lint introduced rule 214 in v0.5.0 to detect this naming convention.
fix
Avoid using periods in Salt State file names, except for the file extension. Upgrade to v0.5.0 or newer to get automatic detection.
affects: <0.5.0
gotchaEarlier versions could produce false positives when detecting missing spaces in Jinja variables if the Jinja statement was nested in literal braces. This was fixed in version 0.8.0.
fix
Upgrade to salt-lint 0.8.0 or newer to resolve false positives related to Jinja variable spacing in nested braces.
affects: <0.8.0
gotchaIncorrect quotation or missing leading zeros in file modes (e.g., `mode: 755` instead of `mode: '0755'`) can lead to unintended permissions. Salt-lint fixed several false positives and improved detection for these in version 0.8.0.
fix
Ensure file modes are correctly quoted as strings, typically with a leading zero (e.g., `mode: '0755'`). Upgrade to v0.8.0 or newer for improved detection.
affects: <0.8.0
Errors
Common errors & fixes
salt-lint: command not found
The `salt-lint` executable is not in the system's PATH, or the Python virtual environment where it was installed is not active.
fix
Activate the correct virtual environment (e.g., `source venv/bin/activate`) or run the command using `python -m salt_lint`.
ModuleNotFoundError: No module named 'salt_lint'
The `salt-lint` package (which provides the `salt_lint` module) is either not installed in the active Python environment or the import statement uses an incorrect module name.
fix
Install the package using `pip install salt-lint`. If trying to import, ensure you use `import salt_lint`.
FileNotFoundError: [Errno 2] No such file or directory: 'path/to/nonexistent.sls'
The file or directory path provided as an argument to `salt-lint` does not exist or is misspelled.
fix
Verify the specified path (e.g., `path/to/nonexistent.sls`) and ensure it points to an existing Salt State file or directory.
ruamel.yaml.scanner.ScannerError: while scanning for the next token
There is a syntax error, such as incorrect indentation or a malformed structure, in the Salt State file (`.sls`) being processed.
fix
Review the specified `.sls` file for YAML syntax errors, paying close attention to indentation, spacing, and correct key-value pair formatting.
Upgrade
Version history
0.9.2latest on PyPI · released Feb 9, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
salt-lint — pip install salt-lint · libregistry