Run a command on every machine you reach
Name hosts and Tailscale tags. fleethosts turns them into ssh targets, runs one command on all of them at once, and tells you what each machine gave back.
Install fleethosts as a dependency.
Read https://fleethosts.loadsheet.dev/guide/hosts, then run commands on our machines with resolveHosts and runOnHosts, passing standardPlaces("<our program>").import { resolveHosts, runOnHosts, standardPlaces } from "fleethosts";
const places = standardPlaces("mytool");
const runs = await runOnHosts(
places,
async (remoteCommand) =>
(await resolveHosts(places, ["vps", "tag:servers"], { remoteCommand })).targets,
["uptime", "-p"],
30_000,
{ here: false },
);
for (const run of runs) console.log(run.host, run.exitCode ?? run.error);vps 0
web-1.tail4f2a.ts.net 0
web-2.tail4f2a.ts.net offline in TailscaleThree entries
Section titled "Three entries"No runtime dependencies: fleethosts runs ssh and tailscale from the machine.
An unreachable machine gets an error and no exit code, so it never reads as a failed command.
Built with ViteHub Docs