Add optional pyinfra integration for idempotent server provisioning#8
Draft
Copilot wants to merge 2 commits intocopilot/add-cloud-resource-provisioningfrom
Draft
Add optional pyinfra integration for idempotent server provisioning#8Copilot wants to merge 2 commits intocopilot/add-cloud-resource-provisioningfrom
Copilot wants to merge 2 commits intocopilot/add-cloud-resource-provisioningfrom
Conversation
Co-authored-by: Karthik777 <7102951+Karthik777@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add optional pyinfra integration for idempotent provisioning
Add optional pyinfra integration for idempotent server provisioning
Feb 25, 2026
This was referenced Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds idempotent VPS provisioning via pyinfra as an optional layer over existing SSH/rsync operations. Running
provision()ordeploy()multiple times now only applies necessary changes instead of re-syncing everything.Changes
fastops/infra.py(389 lines)provision()- Full server setup with automatic fallback to SSH when pyinfra unavailabledeploy_infra()- Lightweight compose deployment with drift detectioninstall_docker()- Idempotent Docker installation with user group managementharden_server()- UFW, fail2ban, and sysctl security configurationsetup_caddy()- Caddy reverse proxy with auto-TLS usingfastops.proxy.Caddyfilesetup_compose_stack()- Idempotent compose deployment with.envsupportserver_status()- Server health check (Docker, Caddy, containers, resources)pyproject.toml[project.optional-dependencies]withinfra = ["pyinfra>=3.0"]pip install fastops[infra]fastops/__init__.pyUsage
Implementation Notes
_require_pyinfra()raises helpful ImportError with installation instructionsprovision()anddeploy_infra()automatically fall back to existingvps.deploy()when pyinfra unavailableserver_status()uses SSH only (no pyinfra dependency)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dummy-host/usr/bin/ssh ssh -o StrictHostKeyChecking=accept-new deploy@dummy-host systemctl is-active docker 2>/dev/null || echo stopped(dns block)/usr/bin/ssh ssh -o StrictHostKeyChecking=accept-new deploy@dummy-host docker ps --format "{{.Names}}: {{.Status}}" 2>/dev/null || echo none(dns block)/usr/bin/ssh ssh -o StrictHostKeyChecking=accept-new deploy@dummy-host systemctl is-active caddy 2>/dev/null || echo stopped(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Overview
Add optional pyinfra integration for idempotent VPS/bare-metal provisioning. Currently fastops uses raw SSH/rsync (
run_ssh,sync,deploy) which works but isn't idempotent — runningdeploy()twice rsyncs everything again, and there's no drift detection.pyinfra adds idempotent state management: only changes what needs changing, supports dry-run mode, and handles multi-server deployments natively.
This should be an optional layer — don't force pyinfra as a dependency. It's available via
pip install fastops[infra].Branch off
copilot/add-cloud-resource-provisioning.File 1:
fastops/infra.pyModule docstring
"""Idempotent server provisioning via pyinfra. Install: pip install fastops[infra]"""__all__['provision', 'deploy_infra', 'harden_server', 'install_docker', 'setup_caddy', 'setup_compose_stack', 'server_status']Imports
All pyinfra imports should be lazy (inside function bodies) with clear ImportError messages.
Helper:
_require_pyinfra()Function:
install_docker(user='deploy')Idempotently install Docker on a remote server. Returns list of pyinfra operation results.
Function:
harden_server(ssh_port=22, allowed_ports=None)Idempotent server hardening — UFW, fail2ban, sysctl tweaks.
Function:
setup_caddy(domain, app='app', port=5001, email=None)Idempotently install and configure Caddy as reverse proxy.