|
1 | 1 | # Environment Variables Reference |
2 | 2 |
|
3 | | -Open Resource Broker supports comprehensive environment variable configuration for all settings, enabling flexible deployment across different environments without modifying configuration files. |
| 3 | +Open Resource Broker reads environment variables at startup to override configuration file values. This page documents every variable that is actually implemented. |
4 | 4 |
|
5 | | -## Variable Naming Convention |
| 5 | +## Variable naming convention |
6 | 6 |
|
7 | | -All ORB environment variables follow the pattern: |
8 | | -- **Core settings**: `ORB_<SETTING_NAME>` |
9 | | -- **Provider settings**: `ORB_<PROVIDER>_<SETTING_NAME>` |
10 | | -- **Nested settings**: `ORB_<SECTION>__<SUBSECTION>_<SETTING>` |
| 7 | +- Core settings: `ORB_<SETTING_NAME>` |
| 8 | +- Provider settings: `ORB_<PROVIDER>_<SETTING_NAME>` |
11 | 9 |
|
12 | | -## Precedence Order |
| 10 | +## Precedence order |
13 | 11 |
|
14 | | -Environment variables override configuration file values: |
| 12 | +1. Environment variables (highest precedence) |
| 13 | +2. Configuration file (`config/config.json`) |
| 14 | +3. Default values from `default_config.json` (lowest precedence) |
15 | 15 |
|
16 | | -1. **Environment variables** (highest precedence) |
17 | | -2. **Configuration file** (`config/app_config.json`) |
18 | | -3. **Default values** (lowest precedence) |
| 16 | +## Directory variables |
19 | 17 |
|
20 | | -## Core Application Variables |
| 18 | +These variables are read by `platform_dirs.py` at ORB initialisation time — before the config loader runs — to locate the working directories. They are **not** processed by the config loader itself. |
21 | 19 |
|
22 | | -### Basic Configuration |
23 | 20 | ```bash |
24 | | -# Application environment |
25 | | -ORB_ENVIRONMENT=production |
26 | | -ORB_DEBUG=false |
27 | | -ORB_LOG_LEVEL=INFO |
28 | | - |
29 | | -# Request handling |
30 | | -ORB_REQUEST_TIMEOUT=300 |
31 | | -ORB_MAX_MACHINES_PER_REQUEST=100 |
32 | | - |
33 | | -# Root directory — sets the base for all subdirectories (config, work, logs, health, scripts) |
34 | | -# Per-directory overrides below take precedence over ORB_ROOT_DIR |
| 21 | +# Base directory for all ORB subdirectories. |
| 22 | +# Subdirectory overrides below take precedence over ORB_ROOT_DIR for their |
| 23 | +# respective directory only. |
35 | 24 | ORB_ROOT_DIR=/opt/orb |
36 | 25 |
|
37 | | -# Directory overrides (each overrides ORB_ROOT_DIR for that subdirectory only) |
| 26 | +# Override individual directories (each is independent of ORB_ROOT_DIR) |
38 | 27 | ORB_CONFIG_DIR=/opt/orb/config |
39 | 28 | ORB_WORK_DIR=/opt/orb/work |
40 | 29 | ORB_LOG_DIR=/opt/orb/logs |
41 | | -ORB_HEALTH_DIR=/opt/orb/health |
| 30 | +ORB_SCRIPTS_DIR=/opt/orb/scripts |
| 31 | +ORB_HEALTH_DIR=/opt/orb/health # defaults to <work>/health |
| 32 | +ORB_CACHE_DIR=/opt/orb/.cache # defaults to <work>/.cache |
42 | 33 | ``` |
43 | 34 |
|
44 | | -### Logging Configuration |
| 35 | +When `ORB_CONFIG_DIR` is set and `ORB_ROOT_DIR` is not, the root is inferred as the parent of `ORB_CONFIG_DIR`. |
| 36 | + |
| 37 | +After ticket 2217, directory values resolved at `orb init` time are persisted to `config.json` so subsequent invocations use the same paths without requiring the environment variables to remain set. |
| 38 | + |
| 39 | +## Config loader variables |
| 40 | + |
| 41 | +These variables are read by `ConfigurationLoader._load_from_env()` and override the corresponding config file keys. |
| 42 | + |
| 43 | +### Core application |
| 44 | + |
45 | 45 | ```bash |
46 | | -# Console logging (for HostFactory integration) |
47 | | -ORB_LOGGING_CONSOLE_ENABLED=true |
48 | | -ORB_LOGGING_FILE_ENABLED=false |
49 | | -ORB_LOGGING_FORMAT=json |
| 46 | +ORB_ENVIRONMENT=production # maps to config key: environment |
| 47 | +ORB_DEBUG=false # maps to config key: debug (true/false) |
| 48 | +ORB_LOG_LEVEL=INFO # maps to config key: logging.level |
| 49 | +ORB_LOG_CONSOLE_ENABLED=true # maps to config key: logging.console_enabled |
| 50 | +ORB_REQUEST_TIMEOUT=300 # maps to config key: request.default_timeout (seconds) |
| 51 | +ORB_MAX_MACHINES_PER_REQUEST=100 # maps to config key: request.max_machines_per_request |
| 52 | +ORB_CONFIG_FILE=/path/to/config # maps to config key: config_file |
50 | 53 | ``` |
51 | 54 |
|
52 | | -## AWS Provider Variables |
| 55 | +## AWS provider variables |
| 56 | + |
| 57 | +These are read from the environment and mapped into the provider configuration section. Set them in your shell or pass them via Docker `--env` / `--env-file`. |
| 58 | + |
| 59 | +### Authentication and region |
53 | 60 |
|
54 | | -### Authentication & Region |
55 | 61 | ```bash |
56 | | -# Basic AWS configuration |
57 | 62 | ORB_AWS_REGION=us-west-2 |
58 | 63 | ORB_AWS_PROFILE=production |
59 | 64 |
|
60 | 65 | # IAM role assumption |
61 | 66 | ORB_AWS_ROLE_ARN=arn:aws:iam::123456789012:role/OrbitRole |
62 | 67 | ORB_AWS_EXTERNAL_ID=unique-external-id |
63 | 68 |
|
64 | | -# Direct credentials (not recommended for production) |
| 69 | +# Direct credentials (not recommended for production — prefer IAM roles) |
65 | 70 | ORB_AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE |
66 | 71 | ORB_AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
67 | 72 | ORB_AWS_SESSION_TOKEN=temporary-session-token |
68 | 73 | ``` |
69 | 74 |
|
70 | | -### Service Configuration |
| 75 | +### Service endpoints and retries |
| 76 | + |
71 | 77 | ```bash |
72 | | -# API endpoints |
73 | 78 | ORB_AWS_ENDPOINT_URL=https://ec2.us-west-2.amazonaws.com |
74 | 79 | ORB_AWS_STS_ENDPOINT_URL=https://sts.us-west-2.amazonaws.com |
75 | 80 |
|
76 | | -# Retry configuration |
77 | 81 | ORB_AWS_MAX_RETRIES=3 |
78 | 82 | ORB_AWS_RETRY_MODE=adaptive |
79 | 83 |
|
80 | | -# Request timeouts |
81 | 84 | ORB_AWS_CONNECT_TIMEOUT=60 |
82 | 85 | ORB_AWS_READ_TIMEOUT=300 |
83 | 86 | ``` |
84 | 87 |
|
85 | | -### Infrastructure Defaults |
| 88 | +### Infrastructure defaults |
| 89 | + |
86 | 90 | ```bash |
87 | | -# Network configuration |
88 | 91 | ORB_AWS_SUBNET_IDS='["subnet-12345", "subnet-67890"]' |
89 | 92 | ORB_AWS_SECURITY_GROUP_IDS='["sg-abcdef"]' |
90 | 93 | ORB_AWS_KEY_NAME=my-keypair |
91 | | - |
92 | | -# Instance configuration |
93 | 94 | ORB_AWS_INSTANCE_TYPE=t3.medium |
94 | 95 | ORB_AWS_IMAGE_ID=ami-0abcdef1234567890 |
95 | 96 | ``` |
96 | 97 |
|
97 | | -### Handler Configuration |
98 | | -```bash |
99 | | -# Enable/disable specific handlers |
100 | | -ORB_AWS_HANDLERS__RUNINSTANCES_ENABLED=true |
101 | | -ORB_AWS_HANDLERS__EC2FLEET_ENABLED=true |
102 | | -ORB_AWS_HANDLERS__SPOTFLEET_ENABLED=false |
103 | | -ORB_AWS_HANDLERS__ASG_ENABLED=true |
104 | | - |
105 | | -# Handler-specific settings |
106 | | -ORB_AWS_HANDLERS__EC2FLEET_TARGET_CAPACITY_TYPE=on-demand |
107 | | -ORB_AWS_HANDLERS__SPOTFLEET_ALLOCATION_STRATEGY=diversified |
108 | | -``` |
109 | | - |
110 | | -### Launch Template Configuration |
111 | | -```bash |
112 | | -# Launch template settings (JSON format) |
113 | | -ORB_AWS_LAUNCH_TEMPLATE='{"LaunchTemplateName": "orb-template", "Version": "$Latest"}' |
114 | | - |
115 | | -# Network interfaces (JSON format) |
116 | | -ORB_AWS_LAUNCH_TEMPLATE_NETWORK_INTERFACES='[{ |
117 | | - "DeviceIndex": 0, |
118 | | - "SubnetId": "subnet-12345", |
119 | | - "Groups": ["sg-abcdef"], |
120 | | - "AssociatePublicIpAddress": true |
121 | | -}]' |
122 | | -``` |
| 98 | +## HostFactory integration variables |
123 | 99 |
|
124 | | -## HostFactory Integration Variables |
125 | | - |
126 | | -When using HostFactory scheduler, these variables provide compatibility: |
| 100 | +When running under IBM Spectrum LSF HostFactory, these variables are set by the scheduler and read by ORB's HostFactory adapter. They are not processed by the core config loader. |
127 | 101 |
|
128 | 102 | ```bash |
129 | | -# Directory overrides (HostFactory standard) |
130 | 103 | HF_PROVIDER_CONFDIR=/opt/symphony/hostfactory/conf |
131 | 104 | HF_PROVIDER_WORKDIR=/opt/symphony/hostfactory/work |
132 | 105 | HF_PROVIDER_LOGDIR=/opt/symphony/hostfactory/logs |
133 | | - |
134 | | -# Logging control |
135 | 106 | HF_LOGGING_CONSOLE_ENABLED=false |
136 | 107 | HF_LOGLEVEL=INFO |
137 | | - |
138 | | -# Timeout overrides |
139 | 108 | HF_PROVIDER_ACTION_TIMEOUT=600 |
140 | 109 | ``` |
141 | 110 |
|
142 | | -## Complex Configuration Examples |
143 | | - |
144 | | -### Multi-Environment Setup |
145 | | -```bash |
146 | | -# Development environment |
147 | | -export ORB_ENVIRONMENT=development |
148 | | -export ORB_DEBUG=true |
149 | | -export ORB_AWS_REGION=us-east-1 |
150 | | -export ORB_AWS_PROFILE=dev |
151 | | -export ORB_AWS_INSTANCE_TYPE=t3.micro |
152 | | - |
153 | | -# Production environment |
154 | | -export ORB_ENVIRONMENT=production |
155 | | -export ORB_DEBUG=false |
156 | | -export ORB_AWS_REGION=us-west-2 |
157 | | -export ORB_AWS_PROFILE=prod |
158 | | -export ORB_AWS_ROLE_ARN=arn:aws:iam::123456789012:role/ProdOrbitRole |
159 | | -export ORB_AWS_INSTANCE_TYPE=m5.large |
160 | | -``` |
161 | | - |
162 | | -### Cross-Region Configuration |
163 | | -```bash |
164 | | -# Primary region |
165 | | -export ORB_AWS_REGION=us-east-1 |
166 | | -export ORB_AWS_SUBNET_IDS='["subnet-east-1", "subnet-east-2"]' |
167 | | -export ORB_AWS_SECURITY_GROUP_IDS='["sg-east-web"]' |
168 | | - |
169 | | -# Failover region (separate provider instance) |
170 | | -export ORB_AWS_WEST_REGION=us-west-2 |
171 | | -export ORB_AWS_WEST_SUBNET_IDS='["subnet-west-1", "subnet-west-2"]' |
172 | | -export ORB_AWS_WEST_SECURITY_GROUP_IDS='["sg-west-web"]' |
173 | | -``` |
174 | | - |
175 | | -### JSON Array and Object Values |
176 | | - |
177 | | -For complex nested configurations, use JSON format: |
178 | | - |
179 | | -```bash |
180 | | -# Array values |
181 | | -export ORB_AWS_SUBNET_IDS='["subnet-12345", "subnet-67890", "subnet-abcdef"]' |
182 | | -export ORB_AWS_SECURITY_GROUP_IDS='["sg-web", "sg-app", "sg-db"]' |
183 | | - |
184 | | -# Object values |
185 | | -export ORB_AWS_LAUNCH_TEMPLATE='{ |
186 | | - "LaunchTemplateName": "orb-production", |
187 | | - "Version": "2" |
188 | | -}' |
189 | | - |
190 | | -# Complex nested objects |
191 | | -export ORB_AWS_HANDLERS='{ |
192 | | - "runinstances": {"enabled": true, "priority": 1}, |
193 | | - "ec2fleet": {"enabled": true, "priority": 2}, |
194 | | - "spotfleet": {"enabled": false}, |
195 | | - "asg": {"enabled": true, "priority": 3} |
196 | | -}' |
197 | | -``` |
198 | | - |
199 | | -## Validation and Type Conversion |
| 111 | +## Type conversion |
200 | 112 |
|
201 | | -ORB automatically validates and converts environment variable values: |
202 | | - |
203 | | -- **Strings**: Used as-is |
204 | | -- **Integers**: `ORB_REQUEST_TIMEOUT=300` |
205 | | -- **Booleans**: `true`, `false`, `1`, `0`, `yes`, `no` |
206 | | -- **Arrays**: JSON format `'["item1", "item2"]'` |
207 | | -- **Objects**: JSON format `'{"key": "value"}'` |
208 | | - |
209 | | -## Environment File Support |
210 | | - |
211 | | -Create `.env` file in your configuration directory: |
212 | | - |
213 | | -```bash |
214 | | -# .env file |
215 | | -ORB_ENVIRONMENT=production |
216 | | -ORB_DEBUG=false |
217 | | -ORB_AWS_REGION=us-west-2 |
218 | | -ORB_AWS_PROFILE=prod |
219 | | -ORB_AWS_SUBNET_IDS=["subnet-12345", "subnet-67890"] |
220 | | -``` |
| 113 | +The config loader converts string values automatically: |
221 | 114 |
|
222 | | -Load with: |
223 | | -```bash |
224 | | -# Load environment file |
225 | | -source .env |
| 115 | +| Type | Example | |
| 116 | +|------|---------| |
| 117 | +| Boolean | `true`, `false` | |
| 118 | +| Integer | `300` | |
| 119 | +| Float | `0.5` | |
| 120 | +| JSON array | `'["a", "b"]'` | |
| 121 | +| JSON object | `'{"key": "value"}'` | |
| 122 | +| String | anything else | |
226 | 123 |
|
227 | | -# Or use with Docker |
228 | | -docker run --env-file .env orb-py:latest |
229 | | -``` |
| 124 | +## Security best practices |
230 | 125 |
|
231 | | -## Security Best Practices |
| 126 | +Use IAM roles or AWS profiles rather than static credentials: |
232 | 127 |
|
233 | | -### Recommended Approach |
234 | 128 | ```bash |
235 | | -# Use IAM roles (recommended) |
| 129 | +# Preferred: IAM role assumption |
236 | 130 | export ORB_AWS_ROLE_ARN=arn:aws:iam::123456789012:role/OrbitRole |
237 | 131 |
|
238 | | -# Use AWS profiles (recommended) |
| 132 | +# Preferred: named profile |
239 | 133 | export ORB_AWS_PROFILE=production |
240 | 134 | ``` |
241 | 135 |
|
242 | | -### Avoid in Production |
243 | | -```bash |
244 | | -# Don't use direct credentials in production |
245 | | -export ORB_AWS_ACCESS_KEY_ID=... # Avoid |
246 | | -export ORB_AWS_SECRET_ACCESS_KEY=... # Avoid |
247 | | -``` |
248 | | - |
249 | | -### Secure Storage |
250 | | -- Use AWS Systems Manager Parameter Store |
251 | | -- Use HashiCorp Vault |
252 | | -- Use Kubernetes secrets |
253 | | -- Use Docker secrets |
| 136 | +Avoid committing `ORB_AWS_ACCESS_KEY_ID` / `ORB_AWS_SECRET_ACCESS_KEY` to source control. Use AWS Systems Manager Parameter Store, HashiCorp Vault, Kubernetes secrets, or Docker secrets for credential storage. |
254 | 137 |
|
255 | 138 | ## Troubleshooting |
256 | 139 |
|
257 | | -### Verify Environment Variables |
258 | 140 | ```bash |
259 | | -# List all ORB variables |
| 141 | +# List all ORB variables currently set |
260 | 142 | env | grep ORB_ |
261 | 143 |
|
262 | | -# Test configuration loading |
263 | | -orb system health --verbose |
264 | | - |
265 | | -# Validate AWS configuration |
| 144 | +# Verify AWS configuration |
266 | 145 | orb providers health aws |
267 | 146 | ``` |
268 | 147 |
|
269 | | -### Common Issues |
270 | | - |
271 | 148 | **Invalid JSON format:** |
272 | 149 | ```bash |
273 | | -# Wrong |
274 | | -export ORB_AWS_SUBNET_IDS=["subnet-123"] # Missing quotes |
| 150 | +# Wrong — missing outer quotes |
| 151 | +export ORB_AWS_SUBNET_IDS=["subnet-123"] |
275 | 152 |
|
276 | 153 | # Correct |
277 | | -export ORB_AWS_SUBNET_IDS='["subnet-123"]' # Quoted JSON |
| 154 | +export ORB_AWS_SUBNET_IDS='["subnet-123"]' |
278 | 155 | ``` |
279 | 156 |
|
280 | | -**Type conversion errors:** |
| 157 | +**Boolean format:** |
281 | 158 | ```bash |
282 | | -# Wrong |
283 | | -export ORB_DEBUG=True # Python boolean |
| 159 | +# Wrong — Python-style capitalisation |
| 160 | +export ORB_DEBUG=True |
284 | 161 |
|
285 | 162 | # Correct |
286 | | -export ORB_DEBUG=true # JSON boolean |
| 163 | +export ORB_DEBUG=true |
287 | 164 | ``` |
288 | | - |
289 | | -**Nested delimiter confusion:** |
290 | | -```bash |
291 | | -# Wrong |
292 | | -export ORB_HANDLERS_RUNINSTANCES_ENABLED=true # Single underscore |
293 | | - |
294 | | -# Correct |
295 | | -export ORB_AWS_HANDLERS__RUNINSTANCES_ENABLED=true # Double underscore |
296 | | -``` |
0 commit comments