Skip to main content

Environment Variables

mac env shows, sets, and clears the variables that drive MAC's behavior — registry, master IP, switch credentials, and more.

mac env

~$ mac env # List managed variables and their sources
~$ mac env set KEY=VAL [...] # Save to ~/.mac/env (per-user, persistent)
~$ mac env unset KEY [...] # Remove from ~/.mac/env

File Priority

MAC reads variables from the following files, highest priority first:

  1. ~/.mac/env — Per-user overrides (written by mac env set)
  2. /etc/mango/mac/env — Global defaults (written by the installer; edit as root)

Shell environment variables are ignored for managed variables — always use mac env set so the value survives restarts. The two exceptions are MAC_CONFIG_DIR and MAC_IMAGE_SOURCE, which may be exported in the shell to scope a value to a single invocation or node (useful when $HOME is NFS-shared).

If your $HOME is shared across hosts (e.g. NFS-mounted), keep per-host values like NODE_NAME out of ~/.mac/env; put them in /etc/mango/mac/env instead.

Image Source

MAC_IMAGE_SOURCE selects where MAC images come from: registry (default — pull published images) or local (build from a source checkout via the .build.yml compose overrides). Resolution order is deliberately different from other variables so a per-node build choice can't be masked by an NFS-shared ~/.mac/env:

  1. Process environment (MAC_IMAGE_SOURCE=local mac start master)
  2. /etc/mango/mac/env (global)
  3. ~/.mac/env (user)

The --local / --registry flags on mac pull, mac start, and mac restart override all of the above for one invocation.

Variable Reference

Common

VariableUsed byPurpose
MASTER_IPAgentMaster node IP (required; no default)
MAC_REGISTRYAllContainer image registry (public default repo.mangoboost.io/public-docker/mac)
MAC_CONFIG_DIRAllCompose file directory (default /etc/mango/mac)
MAC_IMAGE_SOURCEAllregistry (default) or local — see Image Source
MAC_AUTH_ENABLEDMasterEnable JWT auth (default true)
MAC_ADMIN_PASSWORDMasterInitial admin password on first start (default admin)
NODE_NAMEAgentOverride node name (default: hostname)
SDK_AGENT_IMAGEAgentmango-sdk-agent image (public default repo.mangoboost.io/public-docker/mango-sdk-agent:latest)
TZAllContainer timezone, IANA name (auto-detected from the host if unset)

Service Ports

VariableUsed byPurpose
MASTER_API_PORTMasterAPI server published port (default 28080)
MASTER_WEB_PORTMasterWeb UI published port (default 23000)
PROMETHEUS_PORTMasterPrometheus published port (default 29090)
LOKI_PORTMasterLoki published port (default 29210)
SNMP_PORTMasterswitch-exporter SNMP port (default 161)
ALERT_RULES_PATHMasterOverride Prometheus alert-rules JSON file path

TLS (HTTPS)

VariableUsed byPurpose
MAC_TLS_ENABLEDMasterEnable HTTPS for api-server and web-ui (default false)
MAC_TLS_CERT_DIRMasterHost directory holding server.crt and server.key
MAC_TLS_PORTMasterAPI server HTTPS port (default 28443)
MAC_WEB_TLS_PORTMasterWeb UI HTTPS port (default 23443)
MAC_TLS_CERT_FILEMasterIn-container path to TLS cert (default /etc/mac/certs/server.crt)
MAC_TLS_KEY_FILEMasterIn-container path to TLS key (default /etc/mac/certs/server.key)

Switch Access

VariableUsed byPurpose
SWITCH_USERMasterSSH username for switch CLI (default admin)
SWITCH_PASSWD_LISTMasterComma-separated SSH password list (tried in order)
SWITCH_PASSWDMasterLegacy single SSH password (used only if _LIST unset)
SNMP_COMMUNITYMasterSNMP community string (default public)

gNMI Streaming Telemetry

switch-exporter streams counters, oper state, and transceiver presence over gNMI from SONiC switches that pass the gNMI capability probe; Dell OS10 and non-gNMI SONiC stay on SNMP automatically, and LLDP topology discovery always remains on SNMP. These knobs are commented out in /etc/mango/mac/env by default (streaming is enabled out of the box):

VariableUsed byPurpose
GNMI_ENABLEDMasterEnable gNMI streaming (default true; set false to force SNMP-only)
GNMI_PORTMastersonic-gnmi server port (default 8080)
GNMI_USERNAMEMastergNMI auth username (empty by default — noTLS/--allow_no_client_auth)
GNMI_PASSWORDMastergNMI auth password (empty by default)
GNMI_TLS_MODEMasterTransport security: none (default), skip-verify, or ca
GNMI_SAMPLE_INTERVAL_SECMasterCounter SAMPLE subscription interval (default 5)
GNMI_PATH_MODEMasterPath profile: auto (default), sonic-db, or openconfig

LLMBoost

VariableUsed byPurpose
LLMBOOST_API_ENDPOINTMasterOverride the LLMBoost model-serving API endpoint (auto-discovered from agents on port 30080 if unset; can also be set at runtime from the LLMBoost page, admin-only)

Inspecting Current State

Run mac env to print every managed variable with its current value and source (user for ~/.mac/env, global for /etc/mango/mac/env).