Orchestration — Coordinating Many Tasks

20 min In Progress

Learning Objectives

  • Tell automation and orchestration apart
  • Read a basic Ansible playbook
  • Build a step runner that rolls back on failure

Automation vs Orchestration

Automation does one task automatically (push a config). Orchestration coordinates many automated tasks together, in order, often across systems: provision a VLAN -> update the firewall rule -> update DNS -> notify Slack. Ansible playbooks are a common orchestration tool.

Real Ansible YAML syntax -- run with `ansible-playbook snmp-config.yml`, not Python.
---
- name: Configure SNMP on all routers
  hosts: routers
  gather_facts: no
  tasks:
    - name: Set SNMP community
      ios_config:
        lines:
          - snmp-server community MyReadOnlyString RO

📝 Exercise: Build a Step Runner With Rollback

Write a function run_workflow(steps) where steps is a list of (description, function) tuples. Run each step in order. If any step raises an exception, print which step failed, stop running further steps, and call any '_undo' function already attached to completed steps in REVERSE order (simple rollback). Track completed steps in a list as you go.

code.py
Output

            
← Back to Chapter