What does Fabric add on top of paramiko?
IntermediateConceptKubernetes, Docker & SSH clients
Answer
Fabric (2.x/3.x) gives a high-level Connection with run, sudo, put, get, cd context managers, and ThreadingGroup for parallel execution across hosts.
from fabric import Connection, ThreadingGroup
c = Connection("web1", user="deploy", connect_kwargs={"key_filename": "~/.ssh/deploy"})
c.put("app.tar.gz", "/tmp/")
c.sudo("systemctl restart app", hide=True)
results = ThreadingGroup("web1", "web2", "web3").run("df -h /", hide=True, warn=True)
for conn, r in results.items():
print(conn.host, r.ok, r.stdout.strip())
warn=True returns failures instead of raising, so one bad host does not abort the whole group.
More on Kubernetes, Docker & SSH clients
How does the official Kubernetes Python client authenticate?BeginnerHow do you list pods with high restart counts using the Python client?BeginnerHow do you patch or scale a Deployment with the Python client?IntermediateHow does `watch.Watch()` work, and what is a `410 Gone`?AdvancedHow do you apply a YAML manifest from Python?AdvancedHow do you use the Docker SDK for Python?Beginner