Skip to main content

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 scoped allows only the programs in this venv's bin/. 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 own bin/python, which the scoped rule covers. (Before runspec 0.70.0 the prelude ran on sh, which the scoped rule doesn't cover, so console runs that carried variables needed --scope all.)
  • --scope all grants NOPASSWD: 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>.asc and /etc/apt/sources.list.d/<name>.list names it with signed-by=, so the key is trusted for that repository only. --apt-suite (default stable) and --apt-components (default main) fill in the rest of the deb line.
  • dnf / yum / zypper: the key goes to /etc/pki/rpm-gpg/RPM-GPG-KEY-<name> and is imported with rpm --import; /etc/yum.repos.d/<name>.repo (or /etc/zypp/repos.d/) has gpgcheck=1, repo_gpgcheck=1 and gpgkey=file:// pointing at that file. --unsigned-metadata sets repo_gpgcheck=0 for 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-bundle for 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 paths (allow and disallow are manual, so an agent can never widen the list). Give one pattern or several, comma- or space-separated inside the quotes (or repeat --pattern); they're all checked first, so one bad pattern adds none:

sudo /opt/venvs/admin/bin/config-file allow '/etc/alloy/*,/etc/systemd/system/alloy.service.d/*'

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 starts 0600.
  • 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 allowed lists 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-run shows it without writing.
  • An existing file keeps its owner, group and mode unless --owner, --group or --mode say otherwise. edit needs each --old-text to 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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runspec-linux-root 0.3.1
File Size Uploaded Provenance Actions
runspec_linux_root-0.3.1.tar.gz 17.4 kB With provenance Details for runspec_linux_root-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for runspec-linux-root 0.3.1
File Interpreter ABI Platform Actions
runspec_linux_root-0.3.1-py3-none-any.whl Python 3 none any Details for runspec_linux_root-0.3.1-py3-none-any.whl

Total release size: 33.8 kB

Release files / runspec_linux_root-0.3.1.tar.gz

Download URL runspec_linux_root-0.3.1.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2fd8a9c13c6de644c0ca891e5365c6147fe9e7e23f78fa530e688c40e1a57409
BLAKE2b-256 checksum
How to use checksums
460fd9f4df66db1c147dd45b95d4a6d21c361b1ad8ee120d3cd12e11f710367d
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 log

Release files / runspec_linux_root-0.3.1-py3-none-any.whl

Download URL runspec_linux_root-0.3.1-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
787ddd877dd564dad40a28698405b6a1938806a442712db24bc5ab369ad968ac
BLAKE2b-256 checksum
How to use checksums
5c52407ab2c3dd3984765accf3c77315aa9135293b605b2b3f6bcc73d80ccafb
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 log

Security for runspec-linux-root 0.3.1

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.

Select from 2 files

Attestation for runspec_linux_root-0.3.1.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 log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page