runspec-linux-root
Linux admin tools that need root, as runspec runnables:
| Tool | What it does | Autonomy |
|---|---|---|
list-upgrades |
List packages with an available upgrade (refreshes the index) | autonomous |
upgrade-packages |
Refresh the index and upgrade every package | confirm |
install-package |
Install packages by name | confirm |
remove-package |
Remove packages (--purge for config files too) |
confirm |
autoremove-packages |
Remove packages nothing depends on (--dry-run to preview) |
confirm |
package-repo list |
List the package repositories configured on the host | autonomous |
package-repo add |
Add or update a repository and its signing key, then refresh it (undone if that fails) | confirm |
package-repo remove |
Remove a repository and its key file | confirm |
system-service <action> |
start, stop, restart, reload, enable or disable a systemd service (--now with enable/disable) |
confirm |
config-file allowed |
Show which paths config-file may write |
autonomous |
config-file write / edit / read |
Write, edit or read a config file as root, only at allowlisted paths; secrets via {{secret:…}} |
confirm |
config-file allow / disallow |
Add or remove an allowlisted path pattern | manual (a person only) |
set-sysctl |
Set a kernel parameter, optionally persisted under /etc/sysctl.d |
confirm |
reboot-host |
Reboot, optionally after a delay | confirm |
enable-passwordless-sudo |
One-time bootstrap: a validated /etc/sudoers.d drop-in |
confirm |
They work across apt, dnf, yum, zypper and pacman (package-repo: all but pacman). The logic lives in
runspec-linux-core. The
everyday tools that never need root are in
runspec-linux.
Install into a root-owned venv
Every tool here declares run_as = "root": root runs this code. So install it
into a venv only root can change. A venv owned by a service account would
let that account edit code root later runs.
sudo python3 -m venv /opt/venvs/admin
sudo /opt/venvs/admin/bin/pip install runspec-linux-root
Who can run them
sudoers decides. An admin runs a tool with sudo:
sudo /opt/venvs/admin/bin/upgrade-packages
runspec checks the process really is root (enforce_run_as) and refuses
otherwise, naming the account to sudo -u to.
From runspec-console or the MCP gateway, the tool is run with sudo -n,
which never prompts for a password, so the admin needs a passwordless sudo rule.
enable-passwordless-sudo installs one:
--scope scopedallows only the programs in this venv'sbin/. That covers direct runs (sudo /opt/venvs/admin/bin/<tool>from a shell or cron) and, with runspec-console / runspec-mcp built on runspec ≥ 0.70.0, console and gateway runs too. Those pass variables to the tool on stdin through a small prelude that runs on the venv's ownbin/python, which the scoped rule covers. (Before runspec 0.70.0 the prelude ran onsh, which the scoped rule doesn't cover, so console runs that carried variables needed--scope all.)--scope allgrantsNOPASSWD: ALL.
Adding a package repository
Vendor install guides (Grafana Alloy, Docker, PostgreSQL, ...) start with "add
our key and repository". package-repo add does that without a shell:
package-repo add grafana \
--apt-url https://apt.grafana.com --apt-key https://apt.grafana.com/gpg-full.key \
--rpm-url https://rpm.grafana.com --rpm-key https://rpm.grafana.com/gpg.key
install-package alloy
system-service enable alloy --now
- One call carries the apt pair and the rpm pair (dnf, yum and zypper). Each host uses the pair for its own package manager, so the same call works on every host in a mixed group. A missing pair is an error naming it.
- apt: the key goes to
/etc/apt/keyrings/<name>.ascand/etc/apt/sources.list.d/<name>.listnames it withsigned-by=, so the key is trusted for that repository only.--apt-suite(defaultstable) and--apt-components(defaultmain) fill in the rest of thedebline. - dnf / yum / zypper: the key goes to
/etc/pki/rpm-gpg/RPM-GPG-KEY-<name>and is imported withrpm --import;/etc/yum.repos.d/<name>.repo(or/etc/zypp/repos.d/) hasgpgcheck=1,repo_gpgcheck=1andgpgkey=file://pointing at that file.--unsigned-metadatasetsrepo_gpgcheck=0for a repository whose metadata isn't signed. - The key is an
https://URL or a file already on the host (http://only with--key-fingerprint). The output lists every key's fingerprint.--key-fingerprint(repeat it, or separate with commas) refuses a key file holding any key you didn't list. Check them with the vendor first. A key file can hold several keys: Grafana's apt file has three. - Then it refreshes just that repository. If the refresh fails (wrong key,
bad URL) the files are put back and newly imported rpm keys removed, so a
host is never left with a repository that breaks
apt-get update. On dnf/yum, a new key also clears dnf's cached copy of the old one, so the refresh really checks it. - Running it again with the same values changes nothing (no refresh). A
same-named file it didn't write (one you set up by hand) needs
--replace. On apt, the same URL in another file is refused: apt won't accept one repository with two keys. Remove the old one first. - The key download uses the proxy environment variables, or
--proxy, and--ca-bundlefor a private CA. The package manager uses its own proxy settings.
package-repo remove <name> deletes the repository file and its key file
(unless another repository uses that key), including one set up by hand
following the vendor's guide. Keys already in the rpm database stay.
Writing config files as root
config-file is the narrow root counterpart of filesystem write-file /
edit-file: it writes, edits and reads text files, nothing else (no move,
delete, list or search), and only at paths in this venv's allowlist,
/opt/venvs/admin/runspec_root_files.conf. That file has one pattern per line,
where * matches within one folder and ** any depth:
/etc/alloy/*
/etc/systemd/system/alloy.service.d/*
There's no file at first, so nothing can be written. A person adds a path
(allow and disallow are manual, so an agent can never widen the list):
sudo /opt/venvs/admin/bin/config-file allow '/etc/alloy/*'
Then the agent (or you) can write there:
config-file write /etc/alloy/config.alloy --group alloy --mode 0640 --content '…
basic_auth {
username = "{{secret:grafana-cloud.username}}"
password = "{{secret:grafana-cloud}}"
}
…'
system-service restart alloy
- Secrets work the same way as in
filesystem(runspec-fs 0.6.0): a{{secret:<credential>}}placeholder is filled in on the host from the credential runspec-console sends, and shown as the placeholder in the output. A new file holding a secret starts0600. - The path is resolved first. Its folder is resolved through symlinks and
.., and that real path must match the allowlist. The file itself can't be a symlink. Accounts, sudoers, PAM, the SSH server and root's SSH keys are never written, whatever the allowlist says (config-file allowedlists them). - Each write is atomic and the old file is backed up first to
/opt/venvs/admin/root_file_backups/(owner-only, the last 5 per file), not next to the file, where a service that loads a whole folder would pick it up. The output is a diff;--dry-runshows it without writing. - An existing file keeps its owner, group and mode unless
--owner,--groupor--modesay otherwise.editneeds each--old-textto appear exactly once. - The allowlist file must be owned by root and not writable by group or others, in a venv folder that is root's alone; otherwise every call is refused.
- Every write and allowlist change is an audit event (
root_file.written,root_file.allow,root_file.disallow) naming the path and the credential ids, never a value.
Across a group of hosts
From runspec-console, ask the agent to run it with a host group as the
target: it runs on every host in the group behind one approval, and each host
picks its own apt or rpm details. A saved runbook can hold the whole sequence
(add the repository, install-package, then system-service enable --now).
Metadata
Release files for runspec-linux-root 0.3.0
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 | Actions |
|---|---|---|---|---|
| runspec_linux_root-0.3.0.tar.gz | 16.7 kB | With provenance | Details for runspec_linux_root-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| runspec_linux_root-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for runspec_linux_root-0.3.0-py3-none-any.whl |
Total release size: 32.7 kB
Release files / runspec_linux_root-0.3.0.tar.gz
| Download URL | runspec_linux_root-0.3.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea4f74d39c5f197e1f4cac1e0df93097c7fb39504a6cca1e6e62152885642c99
|
|
BLAKE2b-256 checksum How to use checksums |
613d48c47e5c342cac93ffee6e01b357ed6a8d36a50bb15c6a4c8c267f4d8a4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / runspec_linux_root-0.3.0-py3-none-any.whl
| Download URL | runspec_linux_root-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90dbd54ace6fd129818cb38568ad7cc5d5cf3e6dc75965f25c1127dadbd6f6ab
|
|
BLAKE2b-256 checksum How to use checksums |
cbb0fb55962e1f19c81cda26682ad8ee27cadea0851a5afc730770e1eedb5dbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logSecurity for runspec-linux-root 0.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for runspec_linux_root-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logA 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.