Overview

Date: 2026-05-11

Time: 15:41

Overview

This is an FTL2 AI-loop rule that ensures a host called "stargate" has a hardened SSH configuration and an admin user with key-based access. It follows the observe → condition → action pattern used by the FTL2 reconciliation loop: it observes current state, checks whether remediation is needed, and applies changes if the system has drifted from the desired state.

Usage Patterns

This rule is executed automatically by the FTL2 AI-loop (ftl2-ai-loop). It is not called directly by a user. The loop evaluates observe to gather state, calls condition(state) to decide whether to act, and calls action(ftl) if the condition returns True.

The observe list runs two commands on the target host:


observe = [
    {"name": "admin_user", "module": "command", "params": {"cmd": "id admin"}, "host": "stargate"},
    {"name": "sshd_config", "module": "command", "params": {"cmd": "cat /etc/ssh/sshd_config"}, "host": "stargate"},
]

The action function uses the ftl host accessor pattern — ftl["stargate"] — to call modules sequentially via await:


await ftl["stargate"].user(name="admin", shell="/bin/bash", create_home=True)
await ftl["stargate"].lineinfile(path="/etc/ssh/sshd_config", regexp="^#?PasswordAuthentication", line="PasswordAuthentication no")

API and Configuration

Observe state keys:

Condition triggers (any one triggers action):

Modules used in action: user, file, copy, lineinfile, service

Hardcoded values: SSH public key for ben@bthomass-mac, target host stargate, admin username admin.

Key Behaviors

Relationships