Skip to content

Commit 92079a8

Browse files
committed
feat: implement remaining open tickets
- 2214: Add on_tag_failure config flag (warn/fail) for resource tagging - 2217: orb init persists non-default dir paths to config.json - 2220: Remove default_config.json copy from orb init (confusing noise) - Fix type annotation in init_command_handler.py scripts_dir assignment
1 parent f99a851 commit 92079a8

8 files changed

Lines changed: 443 additions & 223 deletions

File tree

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ nav:
148148
- Traditional Deployment: deployment/traditional.md
149149
- PyPI Setup: deployment/pypi-setup.md
150150
- Security: deployment/security.md
151+
- IAM Permissions: deployment/iam-permissions.md
151152
- Monitoring: deployment/monitoring.md
152153
- Dev Deployment: deployment/dev_deployment_documentation.md
153154
- Operations:
Lines changed: 70 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -1,296 +1,164 @@
11
# Environment Variables Reference
22

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.
44

5-
## Variable Naming Convention
5+
## Variable naming convention
66

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>`
119

12-
## Precedence Order
10+
## Precedence order
1311

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)
1515

16-
1. **Environment variables** (highest precedence)
17-
2. **Configuration file** (`config/app_config.json`)
18-
3. **Default values** (lowest precedence)
16+
## Directory variables
1917

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.
2119

22-
### Basic Configuration
2320
```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.
3524
ORB_ROOT_DIR=/opt/orb
3625

37-
# Directory overrides (each overrides ORB_ROOT_DIR for that subdirectory only)
26+
# Override individual directories (each is independent of ORB_ROOT_DIR)
3827
ORB_CONFIG_DIR=/opt/orb/config
3928
ORB_WORK_DIR=/opt/orb/work
4029
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
4233
```
4334

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+
4545
```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
5053
```
5154

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
5360

54-
### Authentication & Region
5561
```bash
56-
# Basic AWS configuration
5762
ORB_AWS_REGION=us-west-2
5863
ORB_AWS_PROFILE=production
5964

6065
# IAM role assumption
6166
ORB_AWS_ROLE_ARN=arn:aws:iam::123456789012:role/OrbitRole
6267
ORB_AWS_EXTERNAL_ID=unique-external-id
6368

64-
# Direct credentials (not recommended for production)
69+
# Direct credentials (not recommended for production — prefer IAM roles)
6570
ORB_AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
6671
ORB_AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
6772
ORB_AWS_SESSION_TOKEN=temporary-session-token
6873
```
6974

70-
### Service Configuration
75+
### Service endpoints and retries
76+
7177
```bash
72-
# API endpoints
7378
ORB_AWS_ENDPOINT_URL=https://ec2.us-west-2.amazonaws.com
7479
ORB_AWS_STS_ENDPOINT_URL=https://sts.us-west-2.amazonaws.com
7580

76-
# Retry configuration
7781
ORB_AWS_MAX_RETRIES=3
7882
ORB_AWS_RETRY_MODE=adaptive
7983

80-
# Request timeouts
8184
ORB_AWS_CONNECT_TIMEOUT=60
8285
ORB_AWS_READ_TIMEOUT=300
8386
```
8487

85-
### Infrastructure Defaults
88+
### Infrastructure defaults
89+
8690
```bash
87-
# Network configuration
8891
ORB_AWS_SUBNET_IDS='["subnet-12345", "subnet-67890"]'
8992
ORB_AWS_SECURITY_GROUP_IDS='["sg-abcdef"]'
9093
ORB_AWS_KEY_NAME=my-keypair
91-
92-
# Instance configuration
9394
ORB_AWS_INSTANCE_TYPE=t3.medium
9495
ORB_AWS_IMAGE_ID=ami-0abcdef1234567890
9596
```
9697

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
12399

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.
127101

128102
```bash
129-
# Directory overrides (HostFactory standard)
130103
HF_PROVIDER_CONFDIR=/opt/symphony/hostfactory/conf
131104
HF_PROVIDER_WORKDIR=/opt/symphony/hostfactory/work
132105
HF_PROVIDER_LOGDIR=/opt/symphony/hostfactory/logs
133-
134-
# Logging control
135106
HF_LOGGING_CONSOLE_ENABLED=false
136107
HF_LOGLEVEL=INFO
137-
138-
# Timeout overrides
139108
HF_PROVIDER_ACTION_TIMEOUT=600
140109
```
141110

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
200112

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:
221114

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 |
226123

227-
# Or use with Docker
228-
docker run --env-file .env orb-py:latest
229-
```
124+
## Security best practices
230125

231-
## Security Best Practices
126+
Use IAM roles or AWS profiles rather than static credentials:
232127

233-
### Recommended Approach
234128
```bash
235-
# Use IAM roles (recommended)
129+
# Preferred: IAM role assumption
236130
export ORB_AWS_ROLE_ARN=arn:aws:iam::123456789012:role/OrbitRole
237131

238-
# Use AWS profiles (recommended)
132+
# Preferred: named profile
239133
export ORB_AWS_PROFILE=production
240134
```
241135

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.
254137

255138
## Troubleshooting
256139

257-
### Verify Environment Variables
258140
```bash
259-
# List all ORB variables
141+
# List all ORB variables currently set
260142
env | grep ORB_
261143

262-
# Test configuration loading
263-
orb system health --verbose
264-
265-
# Validate AWS configuration
144+
# Verify AWS configuration
266145
orb providers health aws
267146
```
268147

269-
### Common Issues
270-
271148
**Invalid JSON format:**
272149
```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"]
275152

276153
# Correct
277-
export ORB_AWS_SUBNET_IDS='["subnet-123"]' # Quoted JSON
154+
export ORB_AWS_SUBNET_IDS='["subnet-123"]'
278155
```
279156

280-
**Type conversion errors:**
157+
**Boolean format:**
281158
```bash
282-
# Wrong
283-
export ORB_DEBUG=True # Python boolean
159+
# Wrong — Python-style capitalisation
160+
export ORB_DEBUG=True
284161

285162
# Correct
286-
export ORB_DEBUG=true # JSON boolean
163+
export ORB_DEBUG=true
287164
```
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

Comments
 (0)