environment variables
set variables once, restart, and they are in every login shell. no config files to copy around.
two scopes
variables live at one of two levels:
| Scope | How to set | Applies to |
|---|---|---|
| account-wide | env set NAME VALUE | every machine you own |
| per-machine | env set NAME VALUE --machine=<name> | that machine only |
same name in both scopes: the machine value wins. put shared defaults at the account level; override per machine where needed. the flag is --machine=<name> (short form -m=<name>) and can appear anywhere in the command.
setting a variable
<SCREENSHOT: account env editor (press e in the dashboard) with a few variables listed>
ssh
$ ssh dashboard@ironwire.sh env set DATABASE_URL postgres://db.example/app set DATABASE_URL — restart the machine to apply
or scoped to a single machine:
$ ssh dashboard@ironwire.sh env set LOG_LEVEL debug --machine=api set LOG_LEVEL — restart the machine to apply
cli
$ ironwire env set DATABASE_URL postgres://db.example/app set DATABASE_URL — restart the machine to apply $ ironwire env set LOG_LEVEL debug --machine=api set LOG_LEVEL — restart the machine to apply
dashboard
press e for the account-wide env vars screen and add the variable there. for a per-machine variable, select the machine, press Space for the actions popup, and choose env vars.
env set replaces any existing value for that name; setting it again overwrites. everything after the name is joined with spaces to form the value.
names must start with a letter or underscore and contain only letters, digits, and underscores. invalid names are rejected with invalid variable name "<n>" (use letters, digits, and underscore; must not start with a digit). names starting with IRONWIRE_ are refused: names starting with IRONWIRE_ are reserved by the control plane.
when changes take effect
values reach a machine at boot: they are stored encrypted at rest on the platform and injected into the machine when it starts. after a set or rm, restart the machine to apply:
$ ssh dashboard@ironwire.sh restart api restarted api
listing variables
ssh
$ ssh dashboard@ironwire.sh env DATABASE_URL=postgres://db.example/app
cli
$ ironwire env DATABASE_URL=postgres://db.example/app
dashboard
press e to see the account-wide variables; a machine's own variables are under Space → env vars.
env with no subcommand lists the account-wide scope. add --machine=<name> to list a machine's own variables. an empty scope prints no variables.
removing a variable
ssh
$ ssh dashboard@ironwire.sh env rm LOG_LEVEL --machine=api removed LOG_LEVEL — restart the machine to apply
cli
$ ironwire env rm LOG_LEVEL --machine=api removed LOG_LEVEL — restart the machine to apply
dashboard
open the env vars screen (e for account-wide, Space → env vars for a machine) and remove the variable there.
removing a name that does not exist in that scope fails with no variable named "<n>".
injected IRONWIRE_* variables
every machine also receives platform-injected variables at boot. they are applied after yours, so they cannot be shadowed; that is why the IRONWIRE_ prefix is reserved. two are useful in your own programs:
| Variable | Meaning |
|---|---|
IRONWIRE_MACHINE_NAME | this machine's name |
IRONWIRE_MACHINE_IP | this machine's IP address |
a few more IRONWIRE_* variables exist as plumbing for the in-machine
ironwire CLI (where the platform is, how to
authenticate to it). the CLI consumes them automatically and your programs never need to.