Chapter 15: Worked Example: Converting an Ansible Playbook to a Go Temporal Workflow

February 13, 2026 · 3 min read
blog

Series: LLM Development Guide

Chapter 15 of 15

Previous: Chapter 14: Worked Example: Creating a Helm Chart From a Reference Chart

What you’ll be able to do

You’ll be able to migrate a procedural automation (for example, an Ansible playbook) into a durable Temporal workflow:

  • Extract discrete steps from the playbook.
  • Map steps to activities.
  • Implement a workflow that follows your team’s existing Temporal patterns.
  • Add verification and tests so the migration is not faith-based.

TL;DR

  • Start from a working reference workflow in your repo.
  • Paste both the playbook and the reference into the planning prompt.
  • Define activities first, then the workflow.
  • Verify with Temporal workflow tests and any integration checks you can run safely.

Table of contents

Scenario

Example: convert a playbook that creates a Kubernetes namespace and resource quota into a Temporal workflow.

Why this is a good fit:

  • Work is step-based.
  • You want retries and observability.
  • You want an execution history.

Reference inputs

Paste these into your planning prompt:

  • The playbook file (or the relevant section): playbooks/create-namespace.yml.
  • A reference workflow file that represents your team’s patterns.
  • A reference activity implementation file (if you have one).

Suggested commands:

sed -n '1,200p' playbooks/create-namespace.yml

sed -n '1,200p' internal/workflows/provision_cluster.go

ls -la internal/activities || true

Plan and phase structure

A reasonable phase split:

  • Phase 1: define activity I/O and implement activities.
  • Phase 2: implement workflow with retries and timeouts.
  • Phase 3: add tests.
  • Phase 4: register and deploy.

The plan should include verification per phase.

Implementation skeleton (Go)

This is a minimal skeleton to illustrate structure. It is intentionally not a full program.

package workflows

import (
	"time"

	"go.temporal.io/sdk/temporal"
	"go.temporal.io/sdk/workflow"
)

type CreateNamespaceInput struct {
	Namespace string
	CPULimit  string
	MemLimit  string
}

type CreateNamespaceOutput struct {
	Namespace string
}

// CreateNamespaceWorkflow orchestrates namespace creation.
// It assumes there are activities registered for create + quota + verify.
func CreateNamespaceWorkflow(ctx workflow.Context, input CreateNamespaceInput) (*CreateNamespaceOutput, error) {
	logger := workflow.GetLogger(ctx)
	logger.Info("starting namespace workflow", "namespace", input.Namespace)

	ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
		StartToCloseTimeout: 10 * time.Minute,
		RetryPolicy: &temporal.RetryPolicy{
			MaximumAttempts: 3,
		},
	})

	// Pseudocode: adapt to your activity names and input/output types.
	// var nsResult activities.CreateNamespaceOutput
	// err := workflow.ExecuteActivity(ctx, activities.CreateNamespace, activities.CreateNamespaceInput{...}).Get(ctx, &nsResult)
	// if err != nil { return nil, err }

	// var quotaResult activities.CreateResourceQuotaOutput
	// err = workflow.ExecuteActivity(ctx, activities.CreateResourceQuota, activities.CreateResourceQuotaInput{...}).Get(ctx, &quotaResult)
	// if err != nil { return nil, err }

	// var verifyResult activities.VerifyNamespaceOutput
	// err = workflow.ExecuteActivity(ctx, activities.VerifyNamespace, activities.VerifyNamespaceInput{...}).Get(ctx, &verifyResult)
	// if err != nil { return nil, err }

	return &CreateNamespaceOutput{Namespace: input.Namespace}, nil
}

Notes:

  • The workflow.ExecuteActivity calls are left as pseudocode because activity package names and types are repo-specific.
  • Keep the skeleton syntactically correct.
  • Use your reference workflow as the style guide.

Verification

Your verification should include at least one of these:

  • Temporal workflow unit tests (Temporal test framework).
  • Activity unit tests (mock external systems).
  • A safe integration test against a non-production environment.

Example commands (adapt to your repo):

# Run unit tests.
go test ./...

# If you have a focused workflow test package.
go test ./internal/workflows -run TestCreateNamespaceWorkflow

Expected results:

  • Tests exit with code 0.
  • Failures are actionable (not timeouts with no logs).

Gotchas

  • If you skip the reference workflow, your new workflow will not match team patterns.
  • If you skip tests, you will not know whether retries and timeouts behave correctly.
  • LLMs will happily invent Temporal APIs. Verify imports and method names exist in your actual SDK version.
Authors
DevOps Architect · Applied AI Engineer
I’ve spent 20 years building systems across embedded firmware, security platforms, fintech, and enterprise architecture. Today I focus on production AI systems in Go — multi-agent orchestration, MCP server ecosystems, and the DevOps platforms that keep them running. I care about systems that work under pressure: observable, recoverable, and built to last.