Interview Prep/Ansible/Fundamentals and Architecture

How does SSH multiplexing (ControlPersist) speed up Ansible?

AdvancedConceptFundamentals and Architecture
Answer

Every task normally needs an SSH connection. With ControlMaster/ControlPersist, the first connection to a host opens a master socket that stays alive in the background, and later tasks reuse it, skipping the TCP handshake, key exchange and authentication.

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
control_path_dir = ~/.ansible/cp

These are already the defaults for the ssh plugin. Watch out for long socket paths: the Unix socket path limit (about 104 chars) causes unix_listener: path too long errors on deep home dirs or long hostnames, so keep control_path_dir short.

All Ansible questions Roadmap: Ansible

More on Fundamentals and Architecture