feat: add RFC 7386 JSON Merge Patch overlays for environment lab configs#139
Merged
Conversation
…rce handling **Added:** - Introduced strongly typed LabConfig, HostConfig, DomainConfig, and related struct types to represent GOAD config.json structure in the variant generator - Added fileExists utility for robust file existence checks in config package - Implemented additional test coverage for variant and config logic, especially around variant config resolution and new struct-based generator operations **Changed:** - Refactored generator to operate directly on typed config structures instead of generic map[string]any, improving code safety and maintainability - Updated all transformation, mapping, and fixing functions in the generator to use typed access (e.g., config.Lab.Hosts) rather than dynamic map traversal - Improved error handling for file and resource closing throughout the codebase, now logging or propagating close errors for log files, inventory, and builders - Enhanced variant config resolution logic to properly prioritize variant configs if present, and fall back to base config otherwise - Generator now validates structure counts using strongly typed config for consistency checks **Removed:** - Removed legacy dynamic JSON traversal helpers (jsonPath, jsonStr) from the generator in favor of direct typed field access
**Added:** - Automated detection of current hostname, domain join state, and DC status - Automated removal of ADCS features before DC demotion, including conditional reboots and timeout handling - Automated domain controller demotion with secure admin password usage and conditional reboot - Automated domain unjoin process with PowerShell and WMI fallback, plus conditional reboot before hostname change **Changed:** - Updated role documentation to reflect new pre-flight and cleanup automation steps in the hostname change workflow - Reorganized main task file to sequence pre-flight, ADCS removal, DC demotion, domain unjoin, and required reboots before changing the hostname
… for dc demotion **Added:** - Introduced `domain`, `domain_username`, and `domain_password` variables in the AD servers playbook to support module authentication **Changed:** - Switched ADCS feature removal from a custom PowerShell script to the `ansible.windows.win_feature` module for clearer intent and reliability - Replaced DC demotion PowerShell script with `microsoft.ad.domain_controller` module, allowing use of domain credentials and improved idempotency - Updated domain unjoin logic to use `microsoft.ad.membership` instead of PowerShell/WMI, providing better error handling and integration - Enhanced reboot logic after DC demotion and domain unjoin to account for module-reported reboot requirements - Updated `settings_hostname` role documentation to reflect use of native Ansible modules instead of PowerShell scripts **Removed:** - Eliminated custom PowerShell scripts for ADCS removal, DC demotion, and domain unjoin, reducing complexity and risk of script errors
refactor: switch to win_powershell for LAPS and GPO tasks, improve reliability **Added:** - Introduced a dedicated task to wait for LAPS CSE to process GPO after refresh in the `laps_server` role, ensuring password is set properly **Changed:** - Replaced `win_shell` with `win_powershell` for moving servers to LAPS OU, adding explicit error handling and idempotency to improve reliability in `laps_dc` role - Updated documentation in `laps_dc/README.md` and `laps_server/README.md` to reflect use of `win_powershell` instead of `win_shell` for relevant tasks - Refined GPO refresh logic in `laps_server` install workflow to use `win_powershell` and added a wait step for LAPS CSE processing, improving clarity and idempotency - Changed WMI query to use `Get-CimInstance` instead of `Get-WmiObject` for checking computer system state in hostname settings role, aligning with modern PowerShell best practices - Simplified reboot conditionals in hostname settings role by removing checks for `reboot_required` and relying solely on change detection **Removed:** - Removed use of deprecated `Get-WmiObject` cmdlet in favor of `Get-CimInstance` - Eliminated unnecessary or redundant reboot conditional logic in hostname settings tasks ```
…e utilities
**Added:**
- Introduced overlay-based environment config system using RFC 7386 JSON Merge Patch
- Added `.dreadgoad/` and `.envrc` to `.gitignore` for improved local dev ergonomics
- Implemented `cli/internal/jsonmerge/` package for JSON Merge Patch diff and merge
- Added comprehensive unit tests for JSON merge/diff utilities
- Created new overlay files (`*-overlay.json`) for dev, staging, and test in GOAD lab data
- Documented overlay system and merge semantics in `docs/cli.md`, `add_lab.md`, and `provisioning.md`
- Updated `env create` to generate overlay files instead of full config copies
**Changed:**
- Switched CLI and labmap resolution logic to prefer `{env}-overlay.json` merged with `config.json`, falling back to legacy `{env}-config.json` if needed
- Updated `LabConfigPath` logic to cache merged configs in `.dreadgoad/cache/` and auto-invalidate on source change
- Refactored CLI env listing, creation, and variant generation to use overlay system
- Updated variant generator to preserve "password in description" for users during transformation
- Enhanced `ansible/roles/ad/tasks/users.yml` to update user descriptions if changed
**Removed:**
- Deleted full per-environment lab config files (`dev-config.json`, `staging-config.json`, `test-config.json`) in favor of overlays
- Removed legacy logic in env scaffolding that copied entire config files for each environment
**Changed:** - Enhance error handling for cache file renaming by returning combined error if both the rename and cleanup (temporary file removal) fail, providing more context for debugging in `mergedConfigPath` function
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.
Key Changes:
*-overlay.json) support for lab configsAdded:
{env}-overlay.jsonfiles inad/GOAD/data/to override only the fields that differ from the baseconfig.json, reducing duplicationcli/internal/jsonmergepackage provides diff/patch logic and round-trip test coverage
overlays and CLI/config tests to ensure overlay merging produces correct
configs
added to
docs/cli.md, provisioning, and developer docsChanged:
runtime (using cached merged outputs in
.dreadgoad/cache/) and fall back tolegacy
{env}-config.jsonorconfig.jsonif overlays are not presentdreadgoad env createand variant generator - Overlay files are now handledseparately from full configs, and overlays are generated or transformed as
needed for new environments
resolution and merging logic throughout the CLI and provisioning codebase
configuration and clarify steps in host/domain state logic
Removed:
{env}-config.jsonfiles are nolonger created for new environments (but still supported for backward
compatibility)
environment config copies, reducing maintenance effort and merge conflicts