Overview

Date: 2026-05-11

Time: 15:14

Overview

FTL modules are in-process Python functions that replace traditional subprocess-based module execution, achieving 250x+ speedups. This page covers the example scripts demonstrating local execution, remote SSH execution, Ansible module compatibility via the module_loading system, and the two primary APIs (direct function calls and the async Executor API).

Key Concepts

Commands and Syntax

Running examples:


uv run python example_local.py          # No setup required
docker-compose up -d                     # Start test containers for remote
uv run python example_remote.py
docker-compose down

Direct function calls:


from ftl2.ftl_modules import ftl_file, ftl_command, ftl_copy
result = ftl_file(path="/tmp/test.txt", state="touch")
result = ftl_command(cmd="echo hello")
result = ftl_copy(src="/tmp/source.txt", dest="/tmp/dest.txt")

Executor API (async, recommended):


from ftl2.ftl_modules import execute, execute_on_hosts, run, LocalHost

result = await execute("file", {"path": "/tmp/test.txt", "state": "touch"})
result = await run("command", cmd="uptime")

hosts = [LocalHost(name=f"host{i}") for i in range(10)]
results = await execute_on_hosts(hosts, "command", {"cmd": "echo hello"})

SSH remote execution:


from ftl2.ssh import SSHHost
host = SSHHost(hostname="localhost", port=2222, username="testuser",
               password="testpass", disable_host_key_checking=True)
async with host:
    stdout, stderr, rc = await host.run("uptime")
    result = await execute("command", {"cmd": "hostname"}, host=host)

Available modules: file, copy, template, command, shell, uri, geturl, pip — each with a corresponding ftl<name>() function.

Relationships

Exam-Relevant Points