Target Assignment
Assign targets to environments to enable deployments.
Why Assign Targets?
Section titled “Why Assign Targets?”Targets must be assigned to environments to:
- Receive deployments for that environment
- Be included in environment-based target selection
- Participate in the promotion pipeline
Assignment Properties
Section titled “Assignment Properties”Each target-environment assignment includes:
| Property | Description |
|---|---|
| Target | The machine being assigned |
| Environment | The destination environment |
| Priority | Deployment order within environment |
Priority Explained
Section titled “Priority Explained”Priority determines deployment order. Values range from -100 to 100 and default to 50. Higher priority values deploy first:
| Priority | Meaning |
|---|---|
| 100 | First to deploy |
| 80 | Earlier |
| 50 | Default |
| 10 | Later |
| -100 | Last |
Assigning Targets
Section titled “Assigning Targets”From Environment Detail
Section titled “From Environment Detail”┌─────────────────────────────────────────────────────────────┐│ Production - Targets │├─────────────────────────────────────────────────────────────┤│ ││ Assigned Targets (12): ││ ┌────────────────┬──────────┬──────────┬────────────────┐ ││ │ Target │ Status │ Priority │ Actions │ ││ ├────────────────┼──────────┼──────────┼────────────────┤ ││ │ web-prod-01 │ ● Online │ 1 │ [Remove] │ ││ │ web-prod-02 │ ● Online │ 2 │ [Remove] │ ││ │ web-prod-03 │ ● Online │ 3 │ [Remove] │ ││ │ db-prod-01 │ ● Online │ 10 │ [Remove] │ ││ └────────────────┴──────────┴──────────┴────────────────┘ ││ ││ [+ Add Target] ││ │└─────────────────────────────────────────────────────────────┘Click Add Target to assign:
┌─────────────────────────────────────────────────────────────┐│ Add Target to Production │├─────────────────────────────────────────────────────────────┤│ ││ Target: [Select target... ▼] ││ ├── web-prod-04 (Online) ││ ├── web-prod-05 (Online) ││ └── worker-01 (Stale) ││ ││ Priority: [50 ] ││ ││ ┌───────────────────────────────────────────────────────┐ ││ │ Higher priority numbers deploy first (range -100..100).│ ││ │ Use 90+ for web servers, lower for databases. │ ││ └───────────────────────────────────────────────────────┘ ││ ││ [Cancel] [Add] ││ │└─────────────────────────────────────────────────────────────┘Via REST API
Section titled “Via REST API”Target-to-environment assignment is managed in Lens or via
POST /api/v1/environments/{environment_id}/targets. Each call assigns one
target with a priority (assignment is by target ID, not tag):
# Assign a single target with a prioritycurl -X POST "$MANTIS_URL/api/v1/environments/<environment-id>/targets" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"target_id": "<web-prod-04-id>", "priority": 4}'
# Assign multiple targets by repeating the callfor id in <id-4> <id-5> <id-6>; do curl -X POST "$MANTIS_URL/api/v1/environments/<environment-id>/targets" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d "{\"target_id\": \"$id\", \"priority\": 5}"doneEditing Assignments
Section titled “Editing Assignments”Change Priority via API
Section titled “Change Priority via API”Update priorities for multiple targets:
# Update a target's priority within an environment (PATCH by target ID)curl -X PATCH "$MANTIS_URL/api/v1/environments/<environment-id>/targets/<target-id>" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"priority": 1}'Removing Assignments
Section titled “Removing Assignments”Single Removal
Section titled “Single Removal”- Navigate to the environment’s Targets page
- Click Remove next to the target
- Confirm removal
┌─────────────────────────────────────────────────────────────┐│ Remove from Environment │├─────────────────────────────────────────────────────────────┤│ ││ Remove web-prod-01 from Production? ││ ││ The target will no longer receive deployments ││ for this environment. ││ ││ [Cancel] [Remove] ││ │└─────────────────────────────────────────────────────────────┘Bulk Removal
Section titled “Bulk Removal”# Remove targets one at a time (DELETE by target ID)for id in <web-prod-04-id> <web-prod-05-id>; do curl -X DELETE "$MANTIS_URL/api/v1/environments/<environment-id>/targets/$id" \ -H "Authorization: Bearer $TOKEN"doneMultiple Environment Assignments
Section titled “Multiple Environment Assignments”A target can belong to multiple environments. For example, shared-cache-01
can be assigned to both Staging and Production with independent priority
values per environment. Each environment’s Targets page lists the target
separately with its own Remove action.
Assignment Strategies
Section titled “Assignment Strategies”By Server Role
Section titled “By Server Role”Production Environment:├── web-prod-01 (priority: 100) - Canary├── web-prod-02 (priority: 90) - Web tier├── web-prod-03 (priority: 90) - Web tier├── api-prod-01 (priority: 80) - API tier├── api-prod-02 (priority: 80) - API tier└── db-prod-01 (priority: 10) - DatabaseBy Geographic Region
Section titled “By Geographic Region”Production Environment:├── us-east-web-01 (priority: 100)├── us-east-web-02 (priority: 100)├── us-west-web-01 (priority: 90)├── us-west-web-02 (priority: 90)├── eu-west-web-01 (priority: 80)└── eu-west-web-02 (priority: 80)Canary + Fleet
Section titled “Canary + Fleet”Production Environment:├── web-canary-01 (priority: 100) ← Deploys first├── web-prod-01 (priority: 50)├── web-prod-02 (priority: 50)├── web-prod-03 (priority: 50)└── web-prod-04 (priority: 50)Deployment Order
Section titled “Deployment Order”Priority determines order within execution modes (higher priority first):
Sequential Mode
Section titled “Sequential Mode”Priority 100: web-canary-01 (first)Priority 90: web-prod-01 (second)Priority 90: web-prod-02 (second, after web-prod-01)Priority 10: db-prod-01 (last)Rolling Mode
Section titled “Rolling Mode”Targets are ordered by priority, then split into batches of batch_size — batch
boundaries come from the count, not the priority value. With batch_size = 2:
Order (by priority): web-canary-01 (100), web-prod-01 (90), web-prod-02 (90), db-prod-01 (10)
Batch 1: web-canary-01, web-prod-01Batch 2: web-prod-02, db-prod-01Parallel Mode
Section titled “Parallel Mode”All targets in the same step start simultaneously. There is no priority-based ordering or completion tracking in parallel mode — every target in the step fires at once (target priority only affects the order in which targets are listed).
Best Practices
Section titled “Best Practices”1. Plan Your Priority Scheme
Section titled “1. Plan Your Priority Scheme”Define a consistent priority scheme (higher deploys first, range -100..100):
| Priority Range | Purpose |
|---|---|
| 100 | Canary/test targets |
| 90-99 | Web/API tier |
| 70-89 | Backend services |
| 50-69 | Worker nodes |
| <50 | Databases, critical services |
2. Use Tags for Organization
Section titled “2. Use Tags for Organization”Combine tags with environments:
Target: web-prod-01Tags: role: web tier: frontend region: us-eastEnvironment: Production (priority: 100)3. Document Assignments
Section titled “3. Document Assignments”Maintain a record of assignments:
| Target | Environment | Priority | Rationale |
|---|---|---|---|
| web-canary | Production | 100 | First to deploy, catch issues early |
| web-prod-* | Production | 90 | Main web tier |
| db-prod | Production | 10 | Deploy after app servers |
4. Review Regularly
Section titled “4. Review Regularly”Periodically audit assignments:
- Remove decommissioned targets
- Update priorities as needed
- Verify new targets are assigned
Troubleshooting
Section titled “Troubleshooting”Target Not Receiving Deployments
Section titled “Target Not Receiving Deployments”Cause: Target not assigned to environment
Solution: Add target to the environment
Wrong Deployment Order
Section titled “Wrong Deployment Order”Cause: Priority values incorrect
Solution: Review and update priority values
Target in Wrong Environment
Section titled “Target in Wrong Environment”Cause: Incorrect assignment
Solution: Remove from wrong environment, add to correct one
Duplicate Assignments
Section titled “Duplicate Assignments”Cause: Target assigned twice to same environment
Solution: This shouldn’t be possible; check for data issues
Next Steps
Section titled “Next Steps”- Creating Environments - Set up environments
- Environment State - Track deployed versions
- Promotions - Promote between environments
- Overview - Return to environments overview
