Skip to Content
Ansible: Up and Running, 3rd Edition
book

Ansible: Up and Running, 3rd Edition

by Bas Meijer, Lorin Hochstein, René Moser
July 2022
Intermediate to advanced
470 pages
10h 22m
English
O'Reilly Media, Inc.
Book available
Content preview from Ansible: Up and Running, 3rd Edition

Chapter 20. Making Ansible Go Even Faster

Once you start using Ansible on a regular basis, you’ll often find yourself wishing that your playbooks could run more quickly. This chapter presents strategies for reducing the time it takes Ansible to execute playbooks.

SSH Multiplexing and ControlPersist

If you’ve made it this far in the book, you know that Ansible uses SSH as its primary transport mechanism for communicating with servers. In particular, it uses the system SSH program by default.

Because the SSH protocol runs on top of the TCP protocol, when you make a connection to a remote machine with SSH, you need to make a new TCP connection. The client and server must negotiate this connection before you can actually start doing useful work. The negotiation takes a small amount of time, but it adds up if you have to do it many times, so it becomes a “penalty.”

When Ansible runs a playbook it makes many SSH connections, to do things such as copy over files and run modules. Each time Ansible makes a new SSH connection to a host, it has to pay this negotiation penalty.

OpenSSH is the most common implementation of SSH; if you are on Linux or macOS, it is almost certainly the SSH client you have installed on your local machine. OpenSSH supports an optimization called SSH multiplexing, also referred to as ControlPersist, which allows multiple SSH sessions to the same host to share the same TCP connection. This means that the TCP connection negotiation happens only the first time, thus ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kubernetes: Up and Running, 3rd Edition

Kubernetes: Up and Running, 3rd Edition

Brendan Burns, Joe Beda, Kelsey Hightower, Lachlan Evenson
Dive Into Ansible - From Beginner to Expert in Ansible

Dive Into Ansible - From Beginner to Expert in Ansible

James Spurin - Docker Captain, CNCF Ambassador, and Kubestronaut
Docker: Up & Running, 3rd Edition

Docker: Up & Running, 3rd Edition

Sean P. Kane, Karl Matthias

Publisher Resources

ISBN: 9781098109141Errata PageSupplemental Content