Governed job launcher

From RHEcosystemAppEng/agentic-plugins · View interactive version

Governed job launcher is an AI agent skill from the GitHub repository RHEcosystemAppEng/agentic-plugins. Execute governed job launches with check mode, approval gates, phased rollout, and rollback. Use when: - After execution-risk-analyzer has classified the execution risk - "Launch with check mode first", "Run the dry run" - "Execute the job" (after risk analysis) - "Rollback the failed job" NOT for:

How to use this skill

Skill file

Governed Job Launcher

Prerequisites

Required MCP Servers:

Verification: Run the aap-mcp-validator skill with aap-mcp-job-management before proceeding.

IMPORTANT: This skill assumes the execution-risk-analyzer skill has already been executed and its risk assessment is available. Do NOT launch jobs without prior risk analysis for CRITICAL or HIGH risk targets.

When to Use This Skill

Use this skill when:

Do NOT use when:

Workflow

Step 1: Consult Execution Governance Documentation

CRITICAL: Document consultation MUST happen BEFORE any MCP tool invocations.

Document Consultation (REQUIRED - Execute FIRST):

  1. Action: Read execution-governance.md using the Read tool to understand check mode execution, interpretation, phased rollout, and rollback patterns
  2. Output to user: "I consulted execution-governance.md to understand Red Hat's check mode behavior, rollback patterns, and phased rollout strategy."

Step 2: Adapt Execution Strategy Based on Risk Signals

Before launching, incorporate the operational signals from the execution-risk-analyzer skill's report. The launcher adapts its behavior based on what was discovered:

2a. If risk analyzer flagged recent failures:

2b. If risk analyzer flagged check mode not overridable (ask_job_type_on_launch: false):

2c. If risk analyzer flagged shell/command modules:

2d. If risk analyzer flagged no notifications:

2e. If risk analyzer flagged standalone template (no workflow):

Step 3: Execute Based on Risk Level

For CRITICAL / HIGH Risk: Check Mode First

MCP Tool: job_templates_launch_create (from aap-mcp-job-management)

Parameters:

Per Red Hat's Job Templates documentation (Ch. 9): The job_type field supports "check" mode for dry-run execution, and diff_mode shows what would change.

If check mode not overridable (from Step 2b): Skip directly to full execution with elevated human-in-the-loop controls.

For MEDIUM Risk: Direct with Confirmation

Ask user for confirmation, then launch directly with job_type: "run".

For LOW Risk: Direct Execution

Launch with job_type: "run" directly (user has already been informed by risk analyzer).

Step 4: Monitor Job Progress

Poll job status until completion:

MCP Tool: jobs_retrieve (from aap-mcp-job-management)

Parameters:

Poll every few seconds. Status values: pending, waiting, running, successful, failed, error, canceled.

Step 5: Interpret Check Mode Results (CRITICAL/HIGH only)

After check mode completes, retrieve results:

MCP Tool: jobs_job_host_summaries_list (from aap-mcp-job-management)

Parameters:

MCP Tool: jobs_job_events_list (from aap-mcp-job-management)

Parameters:

Interpretation (per execution-governance.md):

| Host Summary | Meaning | Action |

|---|---|---|

| failures > 0 | Tasks would fail | STOP -- report failures, do NOT proceed |

| dark > 0 | Hosts unreachable | STOP -- connectivity issue |

| changed > 0, failures = 0 | Changes would be applied successfully | Present findings, ask for approval |

| ok > 0, changed = 0 | Already in desired state | Report: "No changes needed" |

Shell/command module warning (adapted based on risk analyzer findings):

Output to user:

## Check Mode Results — Job #[job_id]

**Status**: [successful/failed]
**Dry-Run Coverage**: [Y] of [Z] tasks validated ([percentage]%) [only if module data available from risk analyzer]

### Host Summary
| Host | OK | Changed | Failed | Unreachable | Skipped |
|---|---|---|---|---|---|
| [host] | [ok] | [changed] | [failures] | [dark] | [skipped] |

### Check Mode Findings
- [X] tasks would make changes
- [Y] tasks would fail
- [Z] tasks were skipped (shell/command — NOT validated)

### Operational Context [from risk analyzer signals]
- Job History: [last run status — clear/failed/first run]
- Notifications: [configured/not configured — silent failures if not]
- Workflow: [wrapped/standalone]

### Recommendation
[Based on results AND operational context: proceed / stop / investigate]

⚠️ [Specific or generic check mode warning based on available data]

**Proceed with full execution?** (yes/no)

Step 6: Full Execution (After Approval)

Standard Execution (HIGH risk or below)

MCP Tool: job_templates_launch_create (from aap-mcp-job-management)

Parameters:

Phased Rollout (CRITICAL risk)

Per execution-governance.md, CRITICAL risk executions use phased rollout:

Phase 1 - Canary:

{
  "id": "<template_id>",
  "requestBody": {
    "job_type": "run",
    "limit": "<canary_host>"
  }
}

Verify canary success via jobs_job_host_summaries_list. If failures = 0, proceed.

Phase 2 - Expanded (25%):

{
  "id": "<template_id>",
  "requestBody": {
    "job_type": "run",
    "limit": "<group>[0:25%]"
  }
}

Verify. If failures = 0, proceed.

Phase 3 - Full Rollout:

{
  "id": "<template_id>",
  "requestBody": {
    "job_type": "run"
  }
}

Health gate between phases: Check jobs_job_host_summaries_list for failures = 0 before proceeding to next phase. If ANY failures, STOP and report.

Step 7: Post-Execution Summary

MCP Tool: jobs_job_host_summaries_list (from aap-mcp-job-management)

Parameters:

Report only hosts with changed > 0 or failures > 0:

## Execution Summary — Job #[job_id]

**Status**: [successful/failed]
**Elapsed**: [time]

### Changed Hosts
| Host | Changed | Failed |
|---|---|---|
| [host] | [changed] | [failures] |

### Result
[X] hosts changed, [Y] hosts failed, [Z] hosts unchanged.

### Proactive Recommendations [based on risk analyzer signals]
[If no notifications were flagged]: "Per Red Hat's Ch. 25, this template has no failure notifications. Now that the execution succeeded, consider adding notifications for future runs."
[If standalone template flagged]: "This template ran outside a workflow. For ongoing production use, consider wrapping it in a workflow with approval nodes."

Step 8: Rollback (If Failure)

If the job fails, offer rollback options per execution-governance.md:

Option 1 - Relaunch on failed hosts:

MCP Tool: jobs_relaunch_create (from aap-mcp-job-management)

Parameters:

Option 2 - Rollback playbook: Launch a different template (if a rollback template exists).

Option 3 - Revert to previous job: Relaunch the last successful job.

Dependencies

Required MCP Servers

Required MCP Tools

Related Skills

Reference Documentation

Critical: Human-in-the-Loop Requirements

This skill requires explicit user confirmation at the following steps:

  1. Before Full Execution (CRITICAL/HIGH risk)
  1. Between Rollout Phases (CRITICAL risk)
  1. Before Rollback

Never execute without approval for CRITICAL or HIGH risk targets.

Example Usage

User: "Execute the security patch on production" (after risk analyzer identified CRITICAL risk with signals)

Agent:

  1. Reads execution-governance.md
  2. Adapts: Risk analyzer flagged last run failed → asks "Last run of this template failed. Investigate first or proceed?"
  3. User says proceed → launches check mode: job_type: "check", diff_mode: true
  4. Adapts: Risk analyzer detected 2 shell tasks → reports: "Dry-run coverage: 4 of 6 tasks validated (67%). 2 shell/command tasks were SKIPPED."
  5. Reports: "Check mode completed. 1 host would have 3 changes, 1 failure detected (dnf package not found). Per Ansible check mode docs, dnf contacts repos in check mode -- this failure is real."
  6. Recommends: "STOP -- check mode detected a failure. Combined with the previous run failure, this template likely has a persistent issue."
  7. Proactive: "Additionally, this template has no failure notifications (per Ch. 25) and runs standalone outside a workflow (per Ch. 9). Consider addressing these governance gaps."
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.