Environment Variables¶
Environment variables (ENV Vars) are configuration values that your application reads at startup. They control database connections, API keys, feature flags, and other runtime settings without touching your code.
On Muppy, ENV Vars are stored in /etc/muppy.env on each server and loaded automatically when you log in via SSH.
How ENV Vars are organized¶
Muppy uses a layered system where higher layers override lower ones:
| Layer | Source | Who manages it |
|---|---|---|
| Computed | Server settings (database, ports, URLs, git tokens) | Muppy (automatic) |
| Vault envfiles | Your custom variables | You |
Vault envfiles have the highest precedence — if you define a variable that Muppy also computes, your value wins.
The variables Muppy writes¶
Muppy computes variables and writes them to /etc/muppy.env. The main ones are below. A
secret one holds a credential: never print it, nor the whole file, which holds others. List
the names, then read the one value you need:
sed -nE 's/^([A-Z0-9_]+)=.*/\1/p' /etc/muppy.env # the names, without their values
printenv APP_HTTP_PORT # one value, by its name; never a secret's
| Variable | What it holds |
|---|---|
APP_HTTP_PORT |
The port your application binds: the exposed port whose Service is http-service, else odoo, else the first one. Absent when the server has no exposed port |
MPY_EXPOSED_PORTS |
The exposed ports that have a Service, as service=port pairs separated by spaces. Absent when there is none |
MPY_EXPOSED_PORT__<SERVICE> |
The port of one service. The service name is in upper case, every character other than a letter or a digit being _ |
APP_LOADBALANCER_URL |
The public URL of the app, which the user can always open; empty if it has none. See The two URLs you are given |
APP_PRIMARY_URL |
The direct URL of the app, whitelisted: it opens from the private network of its host, or, when the host is on a public network, from a whitelisted IP address. See The two URLs you are given |
MPY_REPO_ABS_PATH |
Absolute path of the repository |
MPY_APP_ABS_PATH |
Absolute path of the App Server |
IKB_ENVFILE |
Path of this file, /etc/muppy.env |
MPY_APP_SERVER_QUALIFIER |
The App Server qualifier's short alias (e.g. prod-mono); empty if no qualifier set |
MPY_APP_SERVER_QUALIFIER_CATEGORY |
The category provisioning works by (e.g. Demo → staging, Spark → test); empty if no qualifier set |
PGHOST, PGPORT, PGUSER, PGDATABASE |
The PostgreSQL connection, which psql, pg_dump and ORM libraries read by themselves |
PGPASSWORD |
The password of that connection. Secret |
PGFILTER |
The Database Filter of the App Server; empty if it has none |
The Application URL is APP_LOADBALANCER_URL, or APP_PRIMARY_URL when APP_LOADBALANCER_URL is empty. It is the URL the Open App button opens.
In a script, read the first one, and fall back on the second:
# Shell: APP_LOADBALANCER_URL, or APP_PRIMARY_URL when the first is empty
APP_URL="${APP_LOADBALANCER_URL:-$APP_PRIMARY_URL}"
# Python: the same rule
import os
app_url = os.environ.get("APP_LOADBALANCER_URL") or os.environ.get("APP_PRIMARY_URL")
Defining custom ENV Vars¶
Custom variables are defined through vault envfiles in the ENV Vars tab of your server.
Step by step¶
- Open your server form and go to the ENV Vars tab
- In the Vault ENV Files section, click Add a line
- Give the link a name (e.g. "My app config")
- Choose a scope — Qualifier, User or App Server (see Scopes and qualifiers below)
- Click Edit Vault to open the vault editor
- Enter your variables, one per line:
SMTP_HOST=smtp.example.com SMTP_PORT=587 MY_API_KEY=sk-abc123 REDIS_URL=redis://localhost:6379 - Save the vault, then save the server
Format rules¶
- One
KEY=VALUEper line - Write raw values without quotes — Muppy adds shell-safe quoting automatically so that
/etc/muppy.envcan be sourced by the shell - Lines starting with
#are comments (on their own line) - Inline comments are not supported —
KEY=value # commentwould include# commentas part of the value - Empty lines are ignored
- If the same key is defined in multiple levels, the highest-precedence level wins (vault envfiles > computed > migration)
Do not quote values yourself
Write MY_VAR=hello world, not MY_VAR="hello world".
Muppy wraps every value with shlex.quote() before writing /etc/muppy.env.
If you add your own quotes, they become part of the value (double-quoting).
How ENV Vars reach your server¶
After saving, the Effective /etc/muppy.env section shows the final file that will be written. To push it to the server:
- Click Upload /etc/muppy.env to Host
- The file is written to
/etc/muppy.envon the server - Next SSH login automatically sources it via
~/.bashrc
No restart needed for new SSH sessions
ENV Vars are loaded at each SSH login. Already running processes won't see the changes until they are restarted.
Scopes and qualifiers¶
Every server is created from an App Definition (a template that defines the application type, repository, etc.). Each server also belongs to a qualifier — a category like Development, Staging, or Production that groups servers sharing the same role.
Server code and vault sharing
The {server} part in vault codes comes from your server's code (e.g. mpy18c), chosen at creation time. All servers sharing the same code automatically share the same qualifier-scoped vaults — that's why choosing a meaningful, consistent code matters.
Vault envfiles also use scopes to control how they are attached to servers. Muppy finds the vault of a link by its code, which the scope builds:
| Scope | Vault code pattern | Shared by |
|---|---|---|
| Qualifier | {server}-{qualifier}-{type}-{name} |
Every server with the same code and qualifier. When you create a new Development server from the same App Definition, it automatically gets the qualifier-scoped vaults. |
| User | {server}-{qualifier}-{username}-{type}-{name} |
Every server with the same code and qualifier that runs under the same Unix account — {username} is the server's Username, usually muppy, not your Muppy login. |
| App Server | {app-server-name}-appsrv-{type}-{name} |
This server only. The vault belongs to the server's owner. |
What a vault keeps:
- A Qualifier vault follows the App Definition: at each upload of
/etc/muppy.env, and when you click Update ENV Vars from App. Def., its content is rewritten from the link's default value. - A User or App Server vault is filled from the link's default value once, when it is created. After that it keeps what you write in it.
- An App Server vault stays when its server is deleted, and a server created again under the same name finds it.
- An App Server vault follows its server when the server is renamed: Muppy gives it the new code. A rename also happens without you typing a name: the Refresh button recomputes a server's name unless Force Name is set, from parts such as your user slug or the branch. If a vault already holds the new code, Muppy uses that vault and leaves the old one under its old code.
When to use which:
- Qualifier — team-shared config that every server of that type needs (e.g. shared API endpoints, feature flags)
- User — overrides shared by the servers of one Unix account (e.g. debug settings)
- App Server — config that belongs to one server and must differ from its siblings (e.g. one Sunray worker per LXD host, each with its own settings). Declared on the App Definition, the link gives each server created from it a vault of its own, filled from the default value.