ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.74k stars 3.38k forks source link

Sequential Host Processing in Workflows #14583

Open jangel97 opened 9 months ago

jangel97 commented 9 months ago

Please confirm the following

Feature type

New Feature

Feature Summary

Description:

I would like to have the ability to run a workflow on hosts sequentially within AWX. Specifically, the workflow should complete all its nodes for one host before moving to the next host.

Use Case:

Consider a two-node workflow where:

  1. The first node is responsible for system patching.
  2. The second node reboots the host.

For a given inventory of N hosts, the workflow should:

  1. Patch the first host.
  2. Reboot the first host.
  3. Move on to the second host.
  4. Patch the second host.
  5. Reboot the second host.
  6. Repeat for all hosts in the inventory.

Currently, I achieve this by having a job template that loops over each host and triggers the workflow per host, but this is more of a workaround rather than a native solution.

Motivation:

  1. Safety: In certain environments, especially production, it's crucial to ensure one host is completely processed (including tasks like patching and rebooting) before moving on to the next. This ensures that if something goes wrong, it impacts only one host at a time.

  2. Efficiency: The current method of using a job template to loop over hosts and trigger workflows is an extra layer of complexity. Having this feature natively in AWX would streamline operations and reduce the need for workarounds.

  3. Visibility & Control: Running the workflow sequentially for each host within AWX would provide better visibility into which host is being processed, the progress, and would allow for better error handling.

Proposed Solution:

Introduce a new workflow configuration option, say "Process hosts sequentially", which when enabled, ensures that the workflow completes all its nodes for one host before moving to the next. Maybe this could be achieved by creating a dynamic workflow of workflows per host. The default behavior can remain as it is (parallel processing of hosts), but users can opt-in to this sequential processing based on their needs.

Benefits:

  1. Robustness: This feature would make patching, upgrading, or any other maintenance tasks more robust and safer in environments where sequential processing of hosts is a requirement.

  2. Flexibility: While the parallel processing of hosts is optimal for many scenarios, having the ability to choose sequential processing gives users more flexibility to adapt to different operational requirements.

Select the relevant components

Steps to reproduce

A workflow cannot be run on hosts sequentially within AWX

Current results

One node in workflow processes all the hosts in inventory

Sugested feature result

Workflows can be more flexible and adapt to specific customer needs

Additional information

No response

AlanCoding commented 9 months ago

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_strategies.html#setting-the-batch-size-with-serial

What if you ran a play with serial: 1?

person50002 commented 6 months ago

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_strategies.html#setting-the-batch-size-with-serial

What if you ran a play with serial: 1?

That would not give you the ability to require an approval before moving on to the next host.