semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Feature: Support for Task Chains with Conditional Dependencies

Open fatihusta opened this issue 4 months ago • 2 comments

Related to

Ansible (task execution), Web-Backend (APIs)

Impact

nice to have

Missing Feature

Summary:

Introduce a native feature in Ansible Semaphore to define task chains, where multiple templates (or tasks) can be executed in sequence, with conditional dependencies based on the success or failure of previous tasks.

Problem:

Currently, Semaphore executes templates independently. There is no built-in way to: • Group multiple templates into a single logical workflow • Define conditional execution (e.g., run Template B only if Template A succeeds) • Handle failure gracefully and stop or skip remaining tasks in a chain

This forces users to: • Manually combine playbooks within a single template • Rely on external shell scripts or the Semaphore API to orchestrate templates • Lose visibility and traceability across chained executions

Use Cases: • CI/CD pipelines with clearly defined steps and rollback logic • Zero-downtime deployments with validation gates • Complex orchestration across multiple environments or components

Benefits: • Cleaner automation: No need to combine everything into one huge playbook • Better observability: See each task’s status in the UI and logs • Reusability: Individual templates can be reused across different chains • Scalability: Easier to maintain and expand workflows over time

Implementation

Proposed Solution:

Introduce a Task Chain feature with the following capabilities:

  1. Chain Definition: • A chain is an ordered list of existing templates (or task definitions). • Each step in the chain can have a condition like on_success, on_failure, or always.
  2. Execution Behavior: • Semaphore evaluates the result of each step and decides whether to continue to the next step based on the condition. • If a step fails and the condition for the next step is on_success, the chain stops.
  3. UI/UX Support: • Chains should be visible and manageable through the Semaphore UI. • Each chain execution should be viewable as a sequence with logs for each step.
  4. API Support: • Chains can be triggered via API like templates. • Execution status and logs per step should be available through the API as well.

Task chaining with conditional execution is a critical feature for mature DevOps pipelines. Implementing this natively in Semaphore would dramatically improve workflow management, reduce duplication, and make Semaphore more competitive with modern CI/CD solutions.

Thank you for considering this request.

Design

No response

fatihusta avatar Aug 04 '25 14:08 fatihusta

We also need this feature! 👍

laurivosandi avatar Aug 27 '25 08:08 laurivosandi

Here is another use case that is common in platform teams:

  • Run a playbook to gather information/input for the next playbook
  • Use the output from the first playbook and run the next one.

Example 1: I want to create/modify an existing record of a user in a DB/system/identity management/etc.. First playbook fetches the current entry if exists and fills in the survey form with the values. I modify what I want and run the second playbook that creates/updates the record.

Example 2: Red Hat Satellite with multiple hosts registered. I want to clone a host. The first playbook would gather all the hosts with the necessary information (hostgroups, network etc.) and list them for me. I select a host from a drop down menu that I want to clone and I can enter a hostname for the new host to run the cloning playbook.

Cajga avatar Nov 06 '25 20:11 Cajga