Skip to content

feat: add destroy subcommand to tear down deployed servers#14965

Merged
dguido merged 2 commits intomainfrom
feat/destroy-subcommand
Feb 8, 2026
Merged

feat: add destroy subcommand to tear down deployed servers#14965
dguido merged 2 commits intomainfrom
feat/destroy-subcommand

Conversation

@dguido
Copy link
Copy Markdown
Member

@dguido dguido commented Feb 8, 2026

Summary

  • Add ./algo destroy <server-ip> subcommand to programmatically remove cloud resources and clean up local configs
  • Create destroy.yml playbook that loads server config, gathers provider credentials, confirms with user, and dispatches to provider-specific destroy tasks
  • Add destroy task files for all 11 cloud providers (DigitalOcean, EC2, Lightsail, Azure, GCE, Hetzner, Vultr, Scaleway, OpenStack, CloudStack, Linode)
  • Store algo_region in .config.yml during deployment so destroy can auto-detect region
  • Fix Scaleway custom module to use required_if instead of unconditional required=True for image, commercial_type, organization — enables state: absent without placeholder values
  • Add Vultr to region-required providers and store algo_region in Vultr prompts

Details

The destroy flow:

  1. Validates server_ip is provided
  2. Loads configs/<ip>/.config.yml to get provider, server name, and region
  3. Installs cloud provider dependencies
  4. Gathers credentials via existing prompts.yml files (no duplicated auth logic)
  5. Displays destroy plan and confirms with user (skip with -e confirm_destroy=true)
  6. Dispatches to roles/cloud-<provider>/tasks/destroy.yml
  7. Removes local config directory and localhost symlink if applicable

Provider-specific behavior:

  • EC2/Lightsail: Delete CloudFormation stack (cascading resource cleanup)
  • Azure: Delete entire resource group with force_delete_nonempty
  • GCE: Delete instance + best-effort cleanup of firewall, static IP, network
  • Vultr/OpenStack/CloudStack: Delete instance + best-effort cleanup of firewall/security groups
  • Others: Instance deletion only
  • Local: Config cleanup only (no cloud resources)

Region handling: EC2, Lightsail, GCE, Scaleway, and Vultr require region for deletion. The region is auto-detected from .config.yml for new deployments. For servers deployed before this change, pass -e region=YOUR_REGION.

Test plan

  • ansible-playbook destroy.yml --syntax-check passes
  • ansible-lint destroy.yml passes at production profile
  • pytest tests/unit/test_destroy.py -q — 22 tests pass
  • pytest tests/unit/ -q — full suite (119 tests) passes
  • ./algo destroy shows usage and exits 1
  • ./algo help lists destroy command
  • All pre-commit hooks pass (yamllint, shellcheck, ruff, semgrep, ansible-lint)

🤖 Generated with Claude Code

Add `./algo destroy <server-ip>` to programmatically remove cloud
resources and clean up local configs. Reads provider and server name
from configs/<ip>/.config.yml, gathers credentials via existing
prompts.yml, confirms with user, then dispatches to provider-specific
destroy tasks.

Supports all 11 cloud providers:
- DigitalOcean, EC2, Lightsail (CloudFormation), Azure (resource group),
  GCE (instance + subsidiary resources), Hetzner, Vultr, Scaleway,
  OpenStack, CloudStack, Linode
- Local provider: config cleanup only

Also stores algo_region in .config.yml during deployment so destroy
can auto-detect region. Fixes Scaleway module to allow state=absent
without image/commercial_type/organization params. Adds Vultr to
region-required providers and stores algo_region in Vultr prompts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dguido dguido requested a review from jackivanov as a code owner February 8, 2026 18:19
Add scripts/list_servers.py to scan configs/ for deployed server
metadata and output JSON. Referenced by `./algo list-servers`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dguido dguido merged commit 5a72268 into main Feb 8, 2026
27 checks passed
@dguido dguido deleted the feat/destroy-subcommand branch February 8, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant