Overview

Date: 2026-05-11

Time: 15:49

Overview

This is a complete Azure infrastructure provisioning example that demonstrates FTL2's cloud automation capabilities. It provisions a full web application stack — resource group, virtual network, subnets, security group, public IP, NIC, and a Linux VM — then configures the VM with nginx over SSH. It showcases FTL2's async context manager API, Ansible collection integration (azure.azcollection), secret bindings, state management, dynamic host registration, and check mode, all in a single Python script.

Usage Patterns

Three invocation modes via CLI flags:


uv run python example_azure_web_stack.py            # Full provision + configure
uv run python example_azure_web_stack.py --check     # Dry run (no changes)
uv run python example_azure_web_stack.py --teardown   # Delete everything

The core pattern is async with automation(...) as ftl: — the automation context manager handles setup, collection installation, and cleanup. Modules are called via dot-notation on the ftl object using the FQCN path:


await ftl.azure.azcollection.azure_rm_resourcegroup(
    name=RESOURCE_GROUP,
    location=LOCATION,
    tags={"environment": "demo", "managed_by": "ftl2"},
)

After provisioning, the script dynamically registers the new VM as a host and runs commands against it using host targeting (ftl[VM_NAME].command(...)).

API and Configuration

automation() context manager parameters used:

Required environment variables:

State API:

Dynamic host registration:

Key Behaviors

Relationships