# inframatic inframatic sets up macOS machines and accounts, then checks them for drift. One controller applies the settings to each machine over SSH, or to itself. Settings are records: the CLI writes each one, then reads it back. ## Commands | Command | What it does | | :--------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- | | `inframatic apply [HOST]...` | Applies the roles of each machine and of its accounts, then reads each change back. `--dry-run` prints the plan and changes nothing. | | `inframatic check [HOST]...` | Compares each machine with its records and changes nothing. Exits with `1` when a record drifts. | | `inframatic facts HOST` | Prints the facts that the records test: macOS version, FileVault, SIP, full disk access, Command Line Tools, Homebrew and mpm. | | `inframatic reboot HOST` | Restarts a machine, unlocks FileVault over SSH, then waits for macOS to run. | | `inframatic unlock HOST` | Unlocks FileVault over SSH on a machine that started by itself, like after a power cut. | `check` never writes, so a scheduled drift run cannot change a machine, even with a wrong flag. `apply` and `check` take `--only PATTERN`, a glob on the record IDs, and `--role ROLE` to run part of the records. Each run of `apply` and `check` writes its full log to `~/Library/Logs/inframatic/`. ## Inventory The inventory is a folder of TOML files, one per machine, kept outside any public repository. Pass it with `--inventory`, the `INFRAMATIC_INVENTORY` variable, or the `inventory` key of the configuration file. ```toml roles = ["server"] transport = "ssh" host = "orchard-mac" [[accounts]] name = "alice" roles = ["admin"] [unlock] host = "orchard-mac-unlock" password = "keychain:orchard-mac-alice" ``` `host` is a `Host` alias of the controller's SSH configuration: the transport runs `/usr/bin/ssh`, which applies that configuration as written. `transport = "local"` marks the controller itself. The `unlock` table serves `reboot` and `unlock`. macOS 26 and later run an `sshd` before FileVault unlocks the volume, and a password login there unlocks it (`man apple_ssh_and_filevault`). `host` is the SSH alias of that `sshd`, which takes passwords only. `password` names the password of its account in the controller's login keychain, as `keychain:SERVICE` or `keychain:SERVICE/ACCOUNT`: `ssh` reads it through `SSH_ASKPASS`, so the password never enters a command line or a log. ## Roles Machine roles apply once per machine: `base`, `desktop` and `server`, which include `base`, and `ci`, which includes `server`. Account roles apply once per account: `owner`, `admin` and `guest`. ## Records A record holds one piece of desired state. The records ship with the package, in `inframatic/data/records/`: ```toml [[defaults]] domain = "org.example.weather" key = "Unit" value = "celsius" roles = ["owner"] ``` | Kind | What it sets | | :------------------- | :------------------------------------------------------------------------------------- | | `command-line-tools` | The newest Command Line Tools that `softwareupdate` offers. | | `homebrew` | Homebrew, from the installer package of a pinned release, checked against its SHA-256. | | `formula` | One Homebrew formula, like mpm. | | `packages` | The packages of an mpm file, installed with a cooldown on their release age. | | `file` | The content, mode and owner of a file, written through a checked temporary file. | | `remote-access` | Remote Login or Screen Sharing, on or off. | | `power` | One `pmset` setting, for the charger, the battery, or both. | | `container` | The container of a sandboxed app: the app opens once in the background, then quits. | | `defaults` | One key of a preferences domain, or of a domain inside an app container. | The kinds run in that order: the Command Line Tools, Homebrew and mpm come before the packages they install, the files of the system go in before the services that read them, the first launch of an app creates its container, then the settings go in. Every record takes these keys: | Key | Meaning | | :------ | :------------------------------------------------------------------------------------------ | | `roles` | The roles that apply the record. | | `when` | Facts that must hold, or the record is skipped. | | `gates` | Facts that must hold, or the record is blocked and the report names the step to do by hand. | | `macos` | The macOS versions the record applies to, like `>=27.2.1`. | | `mscp` | The mSCP rule the record implements, like `os_bonjour_disable`. | | `root` | Write as root, like a key of `/Library/Preferences/`. | Two records that set the same key on the same account are an error.