A multi-region data and service mesh run by a Makefile over SSH: encrypted overlay, replicated object storage, label-based ingress. Designed for 150–200 nodes, with no orchestrator, no shared state and a pinned, checksummed supply chain.
Documentation: autoops.readthedocs.io
You need two or more Debian hosts with root SSH access, and python3, make and curl on your machine; pyinfra runs from there.
python3 -m venv .venv && . .venv/bin/activate && pip install -r requirements.txt
make assets # wesher, garage, traefik-kop for x86_64 + aarch64, checksummed
cp examples/inventory.py inventory.py # your hosts: IPs, ssh_user / ssh_port / ssh_key, hostname, zone
make FIRST_IP="203.0.113.10" nodes # base system + firewall, docker, overlay network, s3 cluster
export REDIS_PWD="$(openssl rand -hex 16)" # shared by redis on the bastion and traefik-kop on the workers
export DOMAIN="203-0-113-10.sslip.io" # any name pointing at the bastion; sslip.io works without your own domain
make DOCKERFILES_PATH="examples/dockerfiles" services
make services-up
curl https://$DOMAIN/ # whoami on the worker, routed by traefik on the bastion over the overlay, Let's Encrypt certFIRST_IPis the node the mesh is bootstrapped from, here the bastion.make nodesprints the S3 access key for theautoopsbucket once. Save it, and keepREDIS_PWDfor laterservicesruns.basic.pyenables ufw with incoming traffic denied. It opens the inventory'sssh_port(default 22) first, then HTTP(S), wesher (7946, 51820) and everything on the overlay interface. Garage listens on the overlay only.make checkcompiles the modules without touching any host.- Downloads use
curl, soALL_PROXYworks for them, e.g.ALL_PROXY=socks5h://127.0.0.1:9050 make assets.
- Scalability: Horizontally scalable services within a mesh designed for up to 150–200 nodes.
- Core Mesh Services:
wesher: WireGuard mesh overlay network.garage: Distributed S3-compatible object storage.- Docker, Traefik, Redis, and
traefik-kop.
- Service Discovery: Managed by Traefik and Redis (on bastion hosts) and
traefik-kop(on worker nodes).traefik-kopreads thetraefik.*labels of the local containers and writes routers and services, with the worker's overlay IP as backend, into the bastion's Redis; Traefik uses that Redis as its provider. Redis listens on the overlay IP only. - High Availability: Multiple parallel Traefik/Bastion hosts ensure redundancy.
- Ingress: Handled by a load balancer, VPS providers (floating IPs across DCs) or DNS servers with health checks.
- Stateless Design: Identical Traefik configurations and shared backend access eliminate the need for synchronized state between instances.
- No Redis Sync: Set
traefik_hostto a list of bastions; every worker then runs onetraefik-kop@<bastion>per bastion and publishes its routes to each bastion's Redis, so any bastion can take the traffic.
- Performance: On two 1-vCPU cloud VMs, one bastion served about 1,200–1,600 HTTPS req/s to a minimal backend, the overlay added well under 1 ms of latency, and losing a worker or restarting Traefik caused a few seconds of errors at most. Real services will usually be the bottleneck before the mesh is.
- Bootstrapping: The mesh is initialized from a single node marked by the
FIRST_IPenvironment variable. This IP is used only during setup to bootstrap WireGuard and Garage connections. All other traffic routes through overlay IPs.wesher.pyandgarage.pycan verify or update the first node IP via DNS. Hosts are prepared in parallel; the other nodes wait for the first one, andgarage-layout.pyapplies the storage layout once all nodes have joined.
docker.py: Avoids external APT repositories by downloading packages directly from the official website.services.py: Avoids Docker Hub by building containers from local Dockerfiles. Their base images still come from a registry; the examples use official images, pointFROMat your own registry or mirror if needed.make assets: Pinned releases, checked againstassets/SHA256SUMS.
- Define inventory in
inventory.py(refer to Pyinfra documentation; start fromexamples/inventory.py). - Create a
dockerfiles/directory (seeexamples/dockerfiles) containing:- Subdirectories for each service with a
Dockerfileand build assets. - A
<group>.ymlDocker Compose file for each group ininventory.py(e.g.bastion.yml,worker.yml).
- Subdirectories for each service with a
# Bootstrap nodes and mesh
make FIRST_IP="x.x.x.x" nodes
# Build services from local Dockerfiles (plus the variables your compose files use, e.g. REDIS_PWD)
make DOCKERFILES_PATH="../dockerfiles" services
# Start services
make services-up- Rebuild a specific container on all hosts that run it:
make SERVICE="whoami" deploy - Update/Upgrade APT packages for specific host groups (e.g.,
db*):make GROUP="db*" care GROUPlimits every target to matching hosts or groups.
- Debian-based system with
aptandsystemd. - Prebuilt binaries located in
assets/aarch64andassets/x86_64:wesher,garage,traefik-kop.make assetsdownloads the pinned releases and checks them againstassets/SHA256SUMS. - pyinfra 2 (
requirements.txt), which still runs on older system Pythons such as macOS's 3.9.
hostname(string): Set as the system hostname; used for hostname resolution within the overlay network.behind_nat(bool): Enables LAN service sharing via a Bastion node (Tailscale-like functionality).- Requires
wesher --advertise-addr, which upstream wesher does not have: build neospe/wesher yourself and replaceassets/<arch>/wesher. - Any node can be behind NAT, including the first node. Requires
public_ipand SSH port forwarding. - Supports DynDNS by resolving
public_dnsduring setup steps requiring public routable addresses.
- Requires
services(list): Service names corresponding to subdirectories inDOCKERFILES_PATH.- If you have pet servers rather than cattle, put every host in its own group, each of which has its own compose YAML.
- Traefik: Requires
'traefik'in the services list OR atraefik_hostattribute (the inventory name of a bastion, or a list of them). If neither is present,services.pystops with a notice.
zone: Defines Garage data replication zones.assets/garage.tomlkeeps 2 copies of everything (replication_factor); optimal is a minimum of 3 nodes across 3 locations.- SSH Configuration: pyinfra's connection settings per host:
ssh_user,ssh_portandssh_key(path to the private key;ssh_key_passwordif it has one).- Without
ssh_key, pyinfra uses your SSH agent and the default keys in~/.ssh. - Hosts never connect to each other over SSH; everything goes through your machine. Other credentials may be handled via a vault (refer to Pyinfra documentation).
- Without
- Assumptions:
DOCKERFILES_PATHis defined in the environment or Makefile.- Structure:
DOCKERFILES_PATH/<service>/DockerfileandDOCKERFILES_PATH/<inventory-group>.yml.
- Variables: The group compose file can contain templated variables:
<< OVERLAY_IP >>and<< HOSTNAME >>are filled in per host, everything else comes from the environment (or another secrets handling system feeding it). Examples:<< GARAGE_KEY >>,<< GARAGE_SECRET >>,<< REDIS_PWD >>,<< POSTGRES_PWD >>,<< SMTP_PWD >>. - Traefik: Includes CrowdSec integration (with Docker-specific config). Debian's
crowdsec-firewall-bouncerpackage runs in nftables mode, which covers host-network containers; the packagecloud package runs in iptables mode, for which the bouncer is added to theDOCKER-USERchain. - traefik-kop: Requires Redis running on each
traefik_host, reachable over the overlay, and the sameREDIS_PWDwhen runningservices. Its settings, including the password, are in/etc/traefik-kop/<bastion>.env(root only). It is started byservices-up. - Health checks: Give each service a Traefik health check via labels (see
examples/dockerfiles/worker.yml); a worker that stops answering is then out of rotation within seconds instead of running requests into timeouts. - One service on several workers: add the label
kop.merge-lbs=true, so traefik-kop appends each worker to the service's load balancer instead of replacing it. - TLS: The example bastion gets certificates from Let's Encrypt (HTTP challenge, stored in
/containers/traefik/acme.json) for theHost()rules of the published routers, and redirects HTTP to HTTPS.- With several bastions, the HTTP challenge fails at random: Let's Encrypt may ask a different bastion than the one that ordered the certificate. Use the DNS challenge instead, built into Traefik for most DNS providers: replace the
httpchallengeflag with--certificatesresolvers.le.acme.dnschallenge.provider=<provider>and pass the provider's API token in the container's environment (see Traefik's list of providers). Each bastion then gets its own certificates; Let's Encrypt allows 5 identical certificates per week, enough for a handful of bastions.
- With several bastions, the HTTP challenge fails at random: Let's Encrypt may ask a different bastion than the one that ordered the certificate. Use the DNS challenge instead, built into Traefik for most DNS providers: replace the
- Docker: Uses host network mode. Services are configured to run on the overlay network.
services.pydynamically injects overlay hostname and IP into Compose files (see Variables).
- The
deploytarget builds the new image on all hosts in parallel, then swaps the containers one host at a time and waits until each new container runs (and is healthy, if it has a healthcheck). A service on several hosts stays reachable; on a single host it is gone for a second or two. - The
deploytarget strictly rebuilds containers; it does not update Dockerfiles or assets. Assumes Dockerfiles pull updates from internal version control or object stores. - To update Dockerfiles: Run
make DOCKERFILES_PATH="../dockerfiles" services.
- Redis password: run
servicesandservices-upwith a newREDIS_PWD. Redis, Traefik and traefik-kop restart with it; routes stay in Redis meanwhile, so there is about a second without Traefik per bastion. - Garage RPC secret:
make rotate KEY=garage-rpcwrites a newassets/garage-rpc-secretand restarts Garage on all nodes in the same step (nodes with different secrets can't talk to each other, so don't useGROUPhere). - S3 key:
make rotate KEY=s3 FIRST_IP=...creates a keyautoops-<date>with the same access to theautoopsbucket. Hand it to your services (e.g.<< GARAGE_KEY >>and<< GARAGE_SECRET >>, thenservicesandservices-up), then delete the old one withmake rotate KEY=s3 FIRST_IP=... RETIRE=<key id>. - wesher cluster key:
make rebuild-overlay FIRST_IP=...stops wesher and removes its state on all nodes, then builds a new overlay with a new key. Overlay IPs come from the hostnames and stay the same, so nothing else needs reconfiguring, but everything on the overlay is cut off for about 40 seconds. Also the way out when the overlay gets into a bad state.
-
(Almost) Full ARM64 Support:
docker.pyand the binaries inassets/cover x86_64 and aarch64.services.py: Debian'scrowdsec-firewall-bouncerpackage covers both; the packagecloud fallback is amd64 only (alternative: cs-firewall-bouncer-armv7).
-
Extend
services.py- Environment Injection: Inject variables into Dockerfiles and assets as well (compose files already get them).
- Database State: Restore Postgres and Redis state.
- Note:
chownoperations require UID/GID from inside the container context.
-
Extend
deploy.py- Graceful Rollouts on one host:
docker-rollout(scale up, drain, remove the old container) needs bridge networking and nocontainer_name, so it does not fit host network mode. - Cache Clearing: Clears caches for Traefik and web services (add your webapp logic here).
- Graceful Rollouts on one host:
-
Maintenance (
care)- Add custom backup routines in the
care.pymodule.
- Add custom backup routines in the
-
Logging
- All logs are centralized under
/containers/log. Easily monitored using tools likelnav.
- All logs are centralized under
-
Unprivileged Services
- Wesher
- Can run as an unprivileged user.
- Edit
wesher.service: SetUserandGroup. - Assign binary capabilities:
setcap cap_net_admin=eip wesher. - Note: Hosts file updates require root privileges. Alternative: Sync Wesher state to
/etc/hostsvia a separate task incare.py.
- Garage
- Configure
garage.toml: Setmetadata_dir=/var/lib/garage/metaanddata_dir=/var/lib/garage/data. - Configure
garage.service([Service]section):StateDirectory=garage DynamicUser=true ProtectHome=true NoNewPrivileges=true LimitNOFILE=42000
- Configure
- Docker
- Rootless containers.
- Wesher
-
Roadmap
- Services: Generate Compose files dynamically from snippets and inventory service definitions.
- Inventory: Model in CUE.
- Logging: Implement a log collection service forwarding to a Grafana host.
- Secrets Management: Integrated secrets handling system.
- The overlay is one trusted network: every node reaches every service on every other node.
- Host network mode: no isolation between containers on a host, and services on one host need distinct ports.
- No real dry run: the modules run commands on the hosts while pyinfra prepares the deploy, so
pyinfra --drystill changes things. - Removing a node is manual (
garage layout remove, stop wesher). - Monitoring: the logs in
/containers/log, read withlnavover SSH; no metrics or alerting. - Backups: data in Garage is replicated across zones, but replication is not a backup (deletions replicate too); keep an offsite copy, e.g. via rsync.
- Supply chain:
assets/SHA256SUMSwas pinned on first download (Garage publishes no checksums); Docker packages are pinned by version; base images come from a registry. - pyinfra 2: pyinfra 3 needs Python 3.10+ and API changes in every module.