Skip to content

Instantly share code, notes, and snippets.

@haplo
haplo / ansible-ssh-masters.sh
Created April 7, 2026 09:53
Wrapper script for ansible-playbook that pre-establishes reusable SSH connections
#!/usr/bin/env bash
# ansible-ssh-masters.sh
#
# Establish one SSH master connection per host, keep it alive with a
# remote sleep, run ansible-playbook with all original arguments, then
# clean up only the masters this script started.
#
# Useful when SSH authentication has a per-connection human cost:
# hardware security keys, passphrase prompts, FIDO2/U2F, etc.
#