Fleet designs a set of servers, has a cloud provider make them, turns each into a machine reached only through Mate, and puts software on them, without anyone logging into a server, ever. It runs on the operator's own computer. DigitalOcean is the first provider.
$ fleet model web.fleet # check the design and its formulas, asking no one
$ fleet plan web.fleet # what would change
$ fleet apply web.fleet # do it, after you confirm
$ fleet status web.fleet # every server: green, amber or red, and whyCaptain appears in Fleet in one place: the formulas, the programs that install software on a server. The design itself is not Captain.
The design is TOML
Fleet's specification first planned the design as a Captain module. As
built, it is a TOML file, .fleet, chosen to stay simple for a graphical
editor to change. Fleet checks it itself: the wiring between formulas, and
each formula's program against the inputs the design gives it. So
captain check does not read a .fleet file.
A design names the fleet, its provider and the Mate build its servers run,
then groups of servers and the formulas each group runs, with their inputs.
Following the repository's example
web.fleet:
[fleet]
name = "web"
provider = "digitalocean"
mate = "COMMIT" # the Mate build every server runs
[servers.site]
count = 1
size = "s-1vcpu-512mb-10gb"
region = "sgp1"
formulas = ["static-web"]
[formulas.static-web]
path = "../formulas/static-web"
inputs = { greeting = "Hello from Fleet", page = "https://example.invalid/page.txt", digest = "SHA-256 of that file" }A formula is a Mate program
A formula is a directory holding a Captain program and a formula.toml
naming its entries, its service and its ports:
program = "install.capt"
entry = "install"
remove = "remove"
service = "static-web"
public = [8080]The program uses Mate::Machine, the same commands a person types at
Mate's prompt. This is the repository's test formula,
formulas/static-web/install.capt:
a small website, served by an account of its own:
module Formula::StaticWeb.
use Mate::Machine.
;; Install a small website on this machine: an account that owns nothing,
;; the site, read only by that account, a file fetched by its digest, and a
;; locked-down service, started now and at every boot.
export install greeting: Text page: Text digest: Text -> Text [
account := create account: "static-web".
site := create directory: "/srv/static-web" owner: "root:static-web" mode: "0750".
index := set file: "/srv/static-web/index.html"
text: (("<!doctype html>\n<title>Fleet</title>\n<h1>" append: greeting) append: "</h1>\n").
fetched := fetch file: "/srv/static-web/sums.txt" from: page digest: digest.
indexOwned := set file: "/srv/static-web/index.html" owner: "root:static-web" mode: "0640".
sumsOwned := set file: "/srv/static-web/sums.txt" owner: "root:static-web" mode: "0640".
unit := set service: "static-web"
unit: "# Written by Fleet's static-web formula.\n[Unit]\nDescription=A small website, put here by Fleet\nAfter=network.target\n\n[Service]\nUser=static-web\nGroup=static-web\nExecStart=/usr/bin/python3 -m http.server 8080 --directory /srv/static-web\nRestart=always\nNoNewPrivileges=yes\nProtectSystem=strict\nProtectHome=yes\nPrivateTmp=yes\n\n[Install]\nWantedBy=multi-user.target\n".
atBoot := set service: "static-web" boot: #on.
started := restart service: "static-web".
ret "installed; serving on 8080".
].
;; Take it off this machine: the service stopped, kept from boot, and its
;; unit gone. Its account, directory and files stay, for what they hold.
export remove -> Text [
gone := delete service: "static-web".
ret "removed; its files stay in /srv/static-web".
].A few things make formulas safe to run again and again:
- The commands they use end as asked whatever the starting point: an account or directory already there is no change, and a file already fetched with the right digest is kept. So running a formula twice is harmless.
fetch file:from:digest:keeps a downloaded file only if its SHA-256 matches, so a formula pins what it installs.- A formula declares a
removeentry taking nothing, which Fleet records on the server so it can take the formula off after the design has forgotten it.
What is checked, and where
captain checkaccepts the formula's program like any module that usesMate::Machine.- Fleet, before asking anyone, compiles each formula with Captain's
checker and compares its entry's parameters with the inputs it will get:
the design's, plus
NAME_hostandNAME_portfor each service it needs from another formula. A missing or misspelt input refuses the design, with a coded, placed problem:
$ fleet model bad.fleet
bad.fleet:14:10: error FLEET-INPUT-MISSING: formula `static-web` needs `greeting`, which the design does not give
fleet: bad.fleet does not check- On the server, Fleet sends the program as a request signed with the operator's key, and Mate's executor runs it there, judged by Fleet's rights on that machine. Secrets a formula takes come from the operator's secret store, are sent signed, and are named but never held in Mate's logs.