Skip to content

Target Assignment

Assign targets to environments to enable deployments.

Targets must be assigned to environments to:

  • Receive deployments for that environment
  • Be included in environment-based target selection
  • Participate in the promotion pipeline

Each target-environment assignment includes:

PropertyDescription
TargetThe machine being assigned
EnvironmentThe destination environment
PriorityDeployment order within environment

Priority determines deployment order. Values range from -100 to 100 and default to 50. Higher priority values deploy first:

PriorityMeaning
100First to deploy
80Earlier
50Default
10Later
-100Last
┌─────────────────────────────────────────────────────────────┐
│ 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] │
│ │
└─────────────────────────────────────────────────────────────┘

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

Terminal window
# Assign a single target with a priority
curl -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 call
for 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}"
done

Update priorities for multiple targets:

Terminal window
# 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}'
  1. Navigate to the environment’s Targets page
  2. Click Remove next to the target
  3. Confirm removal
┌─────────────────────────────────────────────────────────────┐
│ Remove from Environment │
├─────────────────────────────────────────────────────────────┤
│ │
│ Remove web-prod-01 from Production? │
│ │
│ The target will no longer receive deployments │
│ for this environment. │
│ │
│ [Cancel] [Remove] │
│ │
└─────────────────────────────────────────────────────────────┘
Terminal window
# 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"
done

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.

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

Priority determines order within execution modes (higher priority first):

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)

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-01
Batch 2: web-prod-02, db-prod-01

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

Define a consistent priority scheme (higher deploys first, range -100..100):

Priority RangePurpose
100Canary/test targets
90-99Web/API tier
70-89Backend services
50-69Worker nodes
<50Databases, critical services

Combine tags with environments:

Target: web-prod-01
Tags:
role: web
tier: frontend
region: us-east
Environment: Production (priority: 100)

Maintain a record of assignments:

TargetEnvironmentPriorityRationale
web-canaryProduction100First to deploy, catch issues early
web-prod-*Production90Main web tier
db-prodProduction10Deploy after app servers

Periodically audit assignments:

  • Remove decommissioned targets
  • Update priorities as needed
  • Verify new targets are assigned

Cause: Target not assigned to environment

Solution: Add target to the environment

Cause: Priority values incorrect

Solution: Review and update priority values

Cause: Incorrect assignment

Solution: Remove from wrong environment, add to correct one

Cause: Target assigned twice to same environment

Solution: This shouldn’t be possible; check for data issues