Skip to main content

Execution Modes

Spage runs tasks in two ways: one after another (sequential) or at the same time (parallel). Choose based on your needs.

Two Modes

  • Sequential - Tasks run one by one in order
  • Parallel - Tasks run together when possible

Both respect task dependencies from before, after, and variables.

Sequential Mode

In this mode, tasks are executed one after the other, in the order they appear in the playbook. This is the default execution mode.

Control-flow keywords such as before and after are ignored, as they are not applicable in sequential mode.

Configuration

spage.yaml
execution_mode: sequential

How it works

playbook.yaml
- name: Task 1
debug: msg="Starting"

- name: Task 2
apt: name=curl state=present

- name: Task 3
debug: msg="Complete"

When to use

  • Development and testing
  • Limited resources
  • Tasks that must run in order
  • Debugging issues

Example config

sequential.yaml
execution_mode: sequential
executor: local
logging:
level: info
format: plain

Parallel Mode

Runs tasks together when dependencies allow.

Configuration

spage.yaml
execution_mode: parallel

How it works

Spage finds task dependencies automatically:

Explicit dependencies

- name: Install package
apt: name=nginx state=present

- name: Start service
systemd: name=nginx state=started
after: Install package # Must wait for install

Variable dependencies

- name: Get system info
setup:
register: system_facts

- name: Use system info
debug: msg="OS is {{ system_facts.ansible_distribution }}"
# Waits for system_facts automatically

Example execution

playbook.yaml
- name: Task A
debug: msg="Task A"
register: task_a_result

- name: Task B
debug: msg="Task B"

- name: Task C (uses A)
debug: msg="Task C needs {{ task_a_result }}"

- name: Task D
debug: msg="Task D"

When to use

If you can clearly define dependencies between tasks and want faster playbook execution, you should use parallel mode.

Example config

parallel.yaml
execution_mode: parallel
executor: local
logging:
level: info
format: json
ssh:
options:
ssh_args: "-o ControlMaster=auto"

Multi-host execution

Sequential mode

Parallel mode