Skip to content

feat: add lab reset and ghost-account purge commands#152

Merged
l50 merged 1 commit into
mainfrom
feat/lab-reset-go
Apr 27, 2026
Merged

feat: add lab reset and ghost-account purge commands#152
l50 merged 1 commit into
mainfrom
feat/lab-reset-go

Conversation

@l50
Copy link
Copy Markdown
Contributor

@l50 l50 commented Apr 27, 2026

Key Changes:

  • Introduced dreadgoad lab reset and dreadgoad lab purge-ghosts subcommands to restore the lab to a known-clean AD baseline without leaving the Go CLI
  • Added a credential-free ghost-account purge that runs Remove-ADComputer on each DC via SSM under the agent's identity, targeting WIN-[A-Z0-9]{11}$ accounts left behind by NoPAC / MachineAccountQuota attempts
  • Extracted a reusable provisionPlaybooks helper so provision and lab reset share the same retry-aware playbook execution path

Added:

  • lab purge-ghosts subcommand - discovers DCs from the inventory's [dc] group, resolves their instance IDs, and runs an idempotent PowerShell purge via SSM (cli/cmd/lab_reset.go)
  • lab reset subcommand - two-stage reset that purges ghost accounts then re-runs the AD-state playbooks (ad-data, ad-acl, ad-relations, ad-trusts, vulnerabilities); supports --skip-purge, --skip-provision, --plays, --limit, --max-retries, --retry-delay (cli/cmd/lab_reset.go)
  • Per-DC ghost purge helpers - collectDCTargets, runGhostPurgeOnDC, and parseRemovedCount to skip hosts without instance IDs, surface SSM stdout/stderr per host, and tally removed accounts (cli/cmd/lab_reset.go)

Changed:

  • Refactored runProvision to delegate to a new provisionPlaybooks(ctx, cfg, playbooks, limit, maxRetries, retryDelay) helper, allowing lab reset to reuse the same preflight, logging, retry, and SSM-cleanup logic (cli/cmd/provision.go)

…nt purge

**Added:**

- Introduced `lab reset` command to reset lab Active Directory state to a
  known-clean baseline, including playbook re-provisioning and ghost account
  cleanup
- Implemented ghost machine account purge logic to remove orphaned
  WIN-[A-Z0-9]{11}$ computer accounts from each DC via SSM
- Added `lab purge-ghosts` subcommand for dedicated ghost account removal
- Added flags to control reset stages (`--skip-purge`, `--skip-provision`,
  `--plays`, etc.) for flexible operation

**Changed:**

- Refactored playbook provisioning logic into new `provisionPlaybooks` function
  for reuse between `provision` and `lab reset` commands in `provision.go`
@l50 l50 changed the title feat: add lab reset command and update dependency versions feat: add lab reset and ghost-account purge commands Apr 27, 2026
@l50 l50 changed the title feat: add lab reset and ghost-account purge commands feat: add lab reset command and update dependency versions Apr 27, 2026
@l50 l50 changed the title feat: add lab reset command and update dependency versions feat: add lab reset and ghost-account purge commands Apr 27, 2026
@l50 l50 merged commit 490e08d into main Apr 27, 2026
8 checks passed
@l50 l50 deleted the feat/lab-reset-go branch April 27, 2026 03: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