English | 繁體中文
Setup your env, both for human and agent, in one command.
anvil is a secure, single-binary Rust tool that sets up the local machine and remote hosts, for humans and agents.
It is agentless: a target needs only POSIX sh, and remote hosts are reached through the system OpenSSH client.
An inventory says where (the hosts) and a config says what (packages, groups, users, directories, files, links, removals,
services, steps),
both stored as TOML in $XDG_CONFIG_HOME/anvil or ~/.config/anvil.
- By default apply works in a fixed order on each target: packages, groups, users, groups to remove, directories, files,
links, removals, services, then steps.
An ordered
[[tasks]]list, with nesting and$/includes, runs in the order you write instead. - Rollback undoes files, directories, links and removals only; packages, groups, users, services and steps cannot be undone. A file others could not read keeps only its hash in the record, so apply warns and rollback names it instead of restoring it.
- With no files yet, the inventory is only
localand the config runshostname, sodoctorandapplyalready pass.
make install # installs `anvil` into ~/.local/bin
cargo install --path . # or: installs `anvil` into ~/.cargo/bin
make build # or: builds target/release/anvilRequires Rust 1.89 or newer and ssh on PATH. Pre-built binaries and install options:
Getting started.
anvil inventory # edit the hosts (opens $EDITOR)
anvil config # edit the packages, groups, users, dirs, files, links, absent, services and steps
anvil config --harden # the Linux hardening the config lacks, as a diff; --write adds it
anvil files cp motd '$/' # keep a file in the store, for [[files]] src = "$/motd"
anvil secret NAME # store a secret
anvil doctor # every target's facts and reachability
anvil plan # the steps apply would run, running none
anvil apply # install packages, copy files, set services, run the steps
anvil run fix.sh # run one sh script on every target
anvil rollback # put back the files the last apply wrote
anvil # all of the above in one terminal UI (also: anvil tui)
anvil update # replace the binary with the latest signed releaseA config, inventory or other local input that others can change is refused until fixed, by every command but
anvil update. A checkout made at umask 002, examples/ included, needs chmod -R go-w . in it.
Files added later, by git pull or an editor, come back 664 and are refused again; set umask 022 in your shell. (Security notes).
--json prints one document on stdout and logs go to stderr (Common flags); --parallel N
works on up to N targets at once (Running in parallel).
- Packages on brew, pacman, apt, dnf and apk, with per-manager aliases, pin and remove (Packages);
anvil lockrecords their versions per platform inanvil.lockandapply --lockedinstalls them (Lock). - Directories, files, links, removals, services and steps, each matched per target by tags and facts (Configuration).
- Local users and groups, with ssh
authorized_keyswritten as the user, behind lockout guards that never remove the login user or root (Users, Groups). - Vars and env per host, tag or globally; steps get the env, and a file with
template = trueis rendered per target with MiniJinja, reading named secrets at apply only (Vars and env, Templating, Secret files). - Plugins write a step's script; drift is a doctor plugin, not a command (Doctor plugins).
- Linux hardening suggested as config entries, with lockout guards:
anvil config --hardenpreviews,--writeadds (Harden). - Secrets in the keychain, age or sops; host keys never auto-accepted; signed updates (Security notes).
[hosts.web1]
host = "203.0.113.10"
user = "deploy"[packages]
install = ["git"]
[[steps]]
run = "hostname"examples/minimal/inventory.toml holds one ssh host and config.toml installs git and runs hostname. Try them on
this machine only (local is always present and never an entry; plan runs nothing):
anvil --inventory examples/minimal/inventory.toml --config examples/minimal/config.toml --target local planexamples/ has more scenarios, each in TOML and YAML.
- Getting started: install, first run and sample output
- Configuration: every key of the inventory and the config
- Command line: every command, flag, exit code and the JSON output
- All docs: the learning path through the rest
| Part | License | What it means |
|---|---|---|
The tool you run (src/, tests/, build files) |
GPL-3.0-or-later | Convey it, modified or not, and you offer its source |
| Examples, reference plugin, docs, these READMEs | MIT | Copy freely; keep the MIT notice and copyright |
Using anvil places no license on your inventory, config, scripts or machines. See LICENSE for the full split and the license texts.