Lesson 1 of 13 · 22m
The Agentless Model: SSH, Python, and No Daemons
What the control node actually ships over SSH, what agentless costs in concurrency and attack surface, and where Python and privilege still hide.
When you run an Ansible task, nothing on the managed node was waiting for it. There is no daemon listening for work, no agent checking in, no persistent process of any kind. The control node opens an SSH connection, ships a self-contained Python program across the wire, runs it — usually wrapped in sudo — collects a JSON blob back, and deletes the temp file. That's the entire mechanism. Everything Ansible does, from apt to template, is a variation on that one loop.
The steps, concretely:
- Resolve the inventory entry — hostname,
ansible_user,ansible_port, variables. - Open (or reuse) an SSH connection as that user.
ControlPersistinssh_argskeeps the transport alive between tasks so you don't pay the handshake forty times a play. - Transfer the module — a Python script plus its arguments — into
~/.ansible/tmp/via SFTP, or piped over stdin whenpipelining = True. - Execute it, parse the JSON it prints (
{"changed": true, ...}), clean up.
Nothing persists. If SSH works and a usable Python 3 interpreter exists on the target, Ansible works. ansible -m ping returning pong verifies exactly those two things — it is not ICMP.
The wrong mental model
"Agentless" gets read two wrong ways. The first: no agent means no requirements. False twice over — the target needs Python (Ansible's modules are Python programs; that's the thing being shipped), and your SSH credentials are the entire security boundary. There is no second layer. The second misreading: no agent means no state. Also false, just relocated. The managed node is stateless, but your inventory, your git history, and your facts cache carry all the state that an agent would have reported. ansible-pull exists for the inverted case — a git-cloned copy of the playbooks on the node itself, run by cron, for machines you can't reach inbound: autoscaled instances, laptops, edge boxes behind NAT.
The people who got this wrong in production: anyone who assumed "agentless" meant "the control node can't hurt me." A playbook you didn't write runs delegate_to: localhost or raw happily on your machine. The SSH-forward direction cuts both ways.
What the wire protocol costs you
Every task is an SSH operation plus a Python startup. That per-task overhead is why forks = 50, pipelining = True, and ControlPersist exist in every serious ansible.cfg — they amortize, they don't eliminate. Orchestrating 5,000 hosts from one control node is bounded by your forks and your patience; agent-based fleets parallelize on the far side by construction. This is a real trade, stated plainly: you gave up the daemon, and in exchange your concurrency ceiling moved to the control node.
There's a quieter cost too: SSH is now your attack surface. The agent-based tools got their CVEs; you get OpenSSH's — regreSSHion (CVE-2024-6387, July 2024) was a signal-handler race in sshd itself, and every node you manage is running one. Keep ForwardAgent off (ssh -A to a managed node hands that node your agent — a compromised web01 can then sign as you anywhere), use ansible_ssh_common_args: -o ProxyJump=bastion for hop-through-bastion instead of forwarding the agent, and don't disable host_key_checking to make warnings go away.
Become: privilege, declared per task
# ansible.cfg
[privilege_escalation]
become = True
become_method = sudo
become_user = root
become_ask_pass = Falsebecome is Ansible's sudo, settable per task, per play, or globally — become_method also accepts runas, doas, su, ksu, machinectl. Declaring it per-task is the point: log in as ansible, escalate only for the three tasks that need root, and your audit log records the escalation that mattered instead of a blanket root session.
Connections that aren't SSH
The mental model survives the transport change. ansible_connection: winrm or psrp manages Windows; ansible.netcommon.network_cli and netconf manage routers and switches; local runs on the control node for API-only targets. Same module-shipping idea — on Windows the payload is PowerShell over WinRM, not Python over SSH.
Field notes
- Connection metadata —
ansible_user,ansible_port,ansible_host,ansible_ssh_private_key_file— are inventory variables, not CLI flags. They live where the host lives. - A target with no Python gets bootstrapped with
raw(ansible -m raw -a "apt install -y python3"), the one module that ships no Python because it's fed straight to/bin/sh. - Agentless does not mean Ansible knows what ran last week. Drift detection is
git logplus--check --diff, not a dashboard — Ansible has no memory you didn't build.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Self-Hosting Prometheus and Grafana: Infrastructure Monitoring That Actually Works
Build a production-grade monitoring stack with Prometheus and Grafana from scratch. Covers architecture, Docker Compose deployment, Node Exporter, alerting with Alertmanager, PromQL from basics to advanced, pre-built dashboards, and everything SudoSecurity uses to monitor its own infrastructure.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
AWS Emulator Puts AWS on Your Laptop. Keep Your IAM Tests Off It.
AWS released AWS Emulator on November 11, a free local server that answers AWS API calls on 127.0.0.1 with per-run keys and fresh certificates.