SSH Pipelining & Connection Reuse
Cut overhead per task.
SSH Pipelining & Connection Reuse is a free Ansible Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
SSH Overhead Adds Up
Every task can mean a fresh login, file copy and execution over SSH. Multiply that by many tasks and many hosts and the overhead dominates the run.
How a Task Normally Runs
By default Ansible copies a module to the host, runs it, then cleans up. Each step costs an SSH round trip you can often avoid.
Pipelining to the Rescue
With pipelining, Ansible streams the module over the existing SSH session instead of writing a temp file first, cutting connections per task.
[ssh_connection]
pipelining = TrueThe requiretty Catch
Pipelining needs sudo without a TTY, so the remote sudoers must not force requiretty. Modern distros are fine; some hardened ones need a tweak.
Reuse the Connection
OpenSSH ControlPersist keeps a master connection open and routes later tasks through it, skipping a brand new handshake each time.
Tune ssh_args
Ansible enables connection reuse through ssh_args. The ControlPersist value sets how long the shared socket stays alive after the last task.
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60sWhere Sockets Live
The shared connection lives in a control path socket file. Keep this path short to dodge the operating system limit on socket name length.
[ssh_connection]
control_path = %(directory)s/%%h-%%p-%%rPipelining vs Reuse
They solve different costs: pipelining trims round trips inside one task, while ControlPersist reuses the SSH session across many tasks.
Use Both Together
Pipelining and persistent connections stack. Turning on both is one of the biggest, lowest-risk speedups you can give a large playbook.
Faster Facts Too
If you do not need facts, set gather_facts: false to skip the setup module. That removes an expensive step from every play's start.
Measure the Win
Enable the profile_tasks callback to time each task. It shows exactly where seconds go so you can confirm your tuning actually helped.
Quick Check
You want each task to avoid writing a temp file before running over SSH.
Recap
Turn on pipelining to trim round trips and ControlPersist to reuse SSH sessions. Together they slash connection overhead on big plays. ⚡
Frequently asked questions
Is the “SSH Pipelining & Connection Reuse” lesson free?
Yes — the full text of “SSH Pipelining & Connection Reuse” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.
What will I learn in “SSH Pipelining & Connection Reuse”?
Cut overhead per task. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ansible Academy?
No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “SSH Pipelining & Connection Reuse” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ansible Academy lesson?
Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- forks & Parallelism Tuning
- Strategies: linear, free & host_pinned
- SSH Pipelining & Connection Reuse
- serial & Rolling Batch Execution