Skip to content

fix: harden Windows reboots and AD group creation against aws_ssm reconnect timeouts - #401

Merged
mwendigg merged 1 commit into
dreadnode:mainfrom
l50:upstream/ansible-run-reliability
Aug 3, 2026
Merged

fix: harden Windows reboots and AD group creation against aws_ssm reconnect timeouts#401
mwendigg merged 1 commit into
dreadnode:mainfrom
l50:upstream/ansible-run-reliability

Conversation

@l50

@l50 l50 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Key Changes:

  • Wrapped all Windows win_reboot tasks in block/rescue patterns that record a pre-reboot boot-time baseline and verify the host actually rebooted, tolerating expected aws_ssm reconnect timeouts across the ad, groups_domains, iis, mssql, trusts, and webdav roles
  • Made AD group creation asynchronous with retries and explicit async_status wait tasks to improve reliability of universal, global, and domainlocal group provisioning
  • Updated Ansible success detection to treat the PLAY RECAP as authoritative, correctly recognizing fatals that were rescued by block/rescue as successful runs
  • Added AWS environment sanitization to drop AWS_PROFILE when explicit access-key/session-token vars are present, resolving the boto3 "profile and access tokens is not supported" error in the aws_ssm connection plugin

Added:

  • Async group creation waits - Added async_status wait tasks for universal, global, and domainlocal groups with retry/delay handling in ansible/roles/ad/tasks/groups.yml, and documented them in the role README
  • Reboot verification pattern - Introduced pre-reboot boot-time baseline capture and block/rescue verification (using Win32_OperatingSystem.LastBootUpTime) across groups_domains, iis, mssql, trusts, and webdav roles to confirm reboots complete despite reconnect timeouts
  • AWS env sanitizer - Implemented sanitizeAWSEnv in cli/internal/ansible/runner.go to prevent boto3 profile+credential conflicts, with warning logging and a comprehensive test suite in the new cli/internal/ansible/runner_test.go
  • Log parser test - Added a test case in cli/internal/ansible/logparser_test.go covering fatals rescued by block/rescue with a clean recap

Changed:

  • Ansible success logic - Modified CheckAnsibleSuccess in cli/internal/ansible/logparser.go so a present PLAY RECAP is authoritative (relying on ansible's failed/unreachable counters) and only falls back to fatal-scanning via the retry indicator when no recap exists
  • AD group tasks - Converted universal, global, and domainlocal group creation to run asynchronously (async: 120, poll: 0) with retries, startup timeout tuning, and result registration
  • Reboot task structure - Replaced direct win_reboot invocations with block/rescue blocks using shorter reboot_timeout/post_reboot_delay values across multiple roles, updating each role README accordingly
  • Environment build - Changed buildEnv to run os.Environ() output through sanitizeAWSEnv
  • Architecture diagram - Regenerated docs/architecture.svg with updated layout dimensions

…lity

**Added:**

- Boot-time baseline capture and block/rescue reboot verification across the `groups_domains`, `iis`, `mssql`, `trusts`, and `webdav` roles, so the expected aws_ssm reconnect timeout during a reboot no longer fails the play — reboots now verify completion via `LastBootUpTime` comparison and retry until the host is back
- Async execution and `async_status` wait tasks for universal, global, and DomainLocal group creation in the `ad` role, with retries to tolerate transient failures during group provisioning
- `sanitizeAWSEnv` helper in the ansible runner that drops `AWS_PROFILE` when explicit `AWS_ACCESS_KEY_ID`/`AWS_SESSION_TOKEN` are present, resolving the boto3 "profile and access tokens is not supported" error in the aws_ssm connection plugin - cli/internal/ansible/runner.go
- Test coverage for the AWS env sanitization logic and for a fatal error rescued by block/rescue with a clean PLAY RECAP - cli/internal/ansible/runner_test.go, logparser_test.go

**Changed:**

- `CheckAnsibleSuccess` now treats an existing PLAY RECAP as authoritative, relying on ansible's failed/unreachable counters (which already discount rescued/ignored fatals) and only scanning for unignored fatals when no recap is present - cli/internal/ansible/logparser.go
- Reduced reboot timeouts to standardized values (300s timeout, 60s post-reboot delay) now that verification is handled explicitly by the rescue logic
- Regenerated architecture diagram and updated role README task listings to reflect the new baseline/reboot block structure - docs/architecture.svg
@dreadnode-renovate-bot dreadnode-renovate-bot Bot added area/roles Changes made to Ansible roles area/docs Changes made to documentation labels Aug 3, 2026
@mwendigg
mwendigg added this pull request to the merge queue Aug 3, 2026
Merged via the queue into dreadnode:main with commit 3e155cb Aug 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Changes made to documentation area/roles Changes made to Ansible roles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants