salt-api-cli
Thin Python CLI for salt-api.
Depends only on the standard library plus rich
(readable output) and typeguard
(JSON validation).
Logs in once with PAM credentials, caches the token in
~/.cache/salt-api-cli/token.json, then invokes salt-api's local,
runner, and wheel clients over HTTPS. The cached token self-heals:
it is refreshed proactively when its stored expiry has passed, and
reactively when the server rejects it (e.g. after the salt-master
container restarts and wipes its session store) — on rejection the CLI
discards the token, logs in again, and retries the request once.
Commands come in two layers:
- Low-level (
local,runner,wheel) map directly to the salt-api clients and print raw JSON. - High-level (
cmd,state,keys) wrap those clients and render readable, colorized output withrich.
Installation
pip install salt-api-cli
Configuration
Configuration is resolved in this order (later sources override earlier):
~/.saltapiclirc— INI file,[salt-api-cli]section- Environment variables —
SALT_API_URL,SALT_API_USER,SALT_API_PASS,SALT_API_INSECURE - Command-line flags —
--url,--user,--password,--insecure,--relogin,--no-token-cache
Example ~/.saltapiclirc:
[salt-api-cli]
url = https://salt.example.com
user = salt_api
password = secret
insecure = false
SALT_API_INSECURE=1 (or insecure = true in the config) skips TLS
certificate verification.
Token cache control: --relogin ignores any cached token and logs in
fresh (re-caching the new token); --no-token-cache neither reads nor
writes the cache for that run; salt logout discards the cached token.
Usage
Low-level commands (raw JSON)
These map one-to-one to the salt-api clients and print the response verbatim as indented JSON.
# Local client — fan out to minions
salt local "*" test.ping
salt local "bml*" cmd.run whoami
salt local "bml1" cmd.run "Get-Date" shell=powershell
# Runner client (master-side: manage.status, jobs.list_jobs, ...)
salt runner manage.status
salt runner jobs.list_jobs
# Wheel client (master-side, low-level)
salt wheel key.list_all
High-level commands (readable, colorized)
These wrap the low-level clients and render their output with rich.
# Run a shell command — a live per-minion checklist while it runs, then
# one block per minion (exit code, stdout, stderr) and an ok/failed summary.
# Fired async (local_async + cmd.run_all) and polled via the runner, like
# `state`, so a slow or wide command never holds one long connection open.
salt cmd "bml*" hostname
salt cmd "bml1" "Get-Date" shell=powershell
# State runs — a colored table of states, one row each, with a summary.
# Driven by the local client + state.* functions.
salt state highstate "bml1" # apply the highstate
salt state test "bml1" # dry-run the highstate (forces test=True)
salt state apply "bml1" veyon # apply specific sls module(s)
salt state apply "bml1" veyon.ldap test=True
# Key management — wraps the wheel client's key.* functions.
# `keys list` shows one colored panel per status (Accepted/Pending/Denied/Rejected).
salt keys list
salt keys accept "<id-or-glob>"
salt keys accept-all
salt keys reject "<id-or-glob>"
salt keys delete "<id-or-glob>"
Color and panels appear when writing to a terminal; output is plain when piped to a file or pager.
Any key=value argument is parsed as a kwarg to the salt function;
anything else is positional.
You can also invoke the CLI as a module: python -m salt_api_cli ....
License
This project is licensed under the terms of the MIT license.
Metadata
Release files for salt-api-cli 1.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| salt_api_cli-1.4.5.tar.gz | 22.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| salt_api_cli-1.4.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.4 kB
Release files / salt_api_cli-1.4.5.tar.gz
| Download URL | salt_api_cli-1.4.5.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9196da02fd26ae9c3c3dedc3062eda43b4b12c76716b05842138c06d5c42144
|
|
BLAKE2b-256 checksum How to use checksums |
2fe052cb97c42f1e7ea293da88ede5af71a2f2df87cfb701bc4b486fa9581377
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / salt_api_cli-1.4.5-py3-none-any.whl
| Download URL | salt_api_cli-1.4.5-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f8fa6e1613edfbf1fe2e33affd45c32dc05231fb32b1b2b5ff999299abd95e7
|
|
BLAKE2b-256 checksum How to use checksums |
e5ab17b098f35edabc59316a46470211363e41875845a4116f72bf6d534de2d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for salt-api-cli 1.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.