feat(stagging): number workflow and add DNS reservations in 0.3.0

This commit is contained in:
Madzone
2026-09-09 09:49:53 +02:00
parent 5f4a214fae
commit 0681874bb2
17 changed files with 548 additions and 95 deletions
+8 -3
View File
@@ -31,7 +31,7 @@ function Get-WindowsPreparationPlan($Settings) {
if ($media -notmatch '^[a-zA-Z]:\\[^<>:"|?*\x00-\x1f]+$' -or $media -match '(?:^|\\)\.{1,2}(?:\\|$)' -or $media -match '[. ](?:\\|$)') { throw 'Medienordner: lokalen absoluten Unterordner verwenden, z.B. C:\Staging\Medien.' }
# Kept separate from media: never put secret answer files in a future webroot.
$drive=$media.Substring(0,2)
return [pscustomobject]@{ WindowsYear=$year; Adapter=$adapter; IP=[string]$Settings['GETAC-IP']; Prefix=$prefix; ScopeId=(ConvertFrom-IPv4Value $network); SubnetMask=(Get-Netmask $prefix); DHCPStart=[string]$Settings['DHCP von']; DHCPEnd=[string]$Settings['DHCP bis']; MediaDirectory=$media; BootDirectory="$drive\Staging-PXE\Boot"; ScopeName='Stagging-KIS'; ScopeDescription='Managed by Stagging Setup-StagingServer v1' }
return [pscustomobject]@{ DnsZone=([string]$Settings['DNS-Zone']).Trim().ToLowerInvariant(); WindowsYear=$year; Adapter=$adapter; IP=[string]$Settings['GETAC-IP']; Prefix=$prefix; ScopeId=(ConvertFrom-IPv4Value $network); SubnetMask=(Get-Netmask $prefix); DHCPStart=[string]$Settings['DHCP von']; DHCPEnd=[string]$Settings['DHCP bis']; MediaDirectory=$media; BootDirectory="$drive\Staging-PXE\Boot"; ScopeName='Stagging-KIS'; ScopeDescription='Managed by Stagging Setup-StagingServer v1' }
}
function Assert-PreparationState($Plan,$State) {
@@ -57,7 +57,12 @@ function Assert-PreparationState($Plan,$State) {
if ([string]$scope.StartRange -ne $Plan.DHCPStart -or [string]$scope.EndRange -ne $Plan.DHCPEnd -or [string]$scope.SubnetMask -ne $Plan.SubnetMask) { throw 'Vorhandener Staging-Bereich weicht von Excel ab. Kein automatisches Ersetzen bestehender Leases.' }
}
if (@($State.Scopes6).Count -gt 0) { throw 'Vorhandene DHCPv6-Bereiche: kein dedizierter leerer Staging-DHCP-Server.' }
if (@($State.Options).Count -gt 0) { throw 'Vorhandene DHCP-Optionen: vor automatischer Einrichtung manuell pruefen (keine impliziten Router-/PXE-Optionen).' }
foreach ($option in $State.Options) {
if (-not ($option.PSObject.Properties.Name -contains 'ScopeId') -or [string]$option.ScopeId -ne $Plan.ScopeId) { throw 'Vorhandene globale DHCP-Optionen: manuell pruefen.' }
$value=@($option.Value) -join ','
if (($option.OptionId -eq 6 -and $value -eq $Plan.IP) -or ($option.OptionId -eq 15 -and $Plan.DnsZone -and $value -eq $Plan.DnsZone)) { continue }
throw 'DHCP-Option weicht vom KIS-Profil ab. Keine automatische Uebernahme.'
}
}
function Get-PreparationState($Plan) {
@@ -78,7 +83,7 @@ function Get-PreparationState($Plan) {
Import-Module DhcpServer
$scopes=@(Get-DhcpServerv4Scope); $scopes6=@(Get-DhcpServerv6Scope); $bindings=@(Get-DhcpServerv4Binding)
$options=@(Get-DhcpServerv4OptionValue)
foreach ($scope in $scopes) { $options+=@(Get-DhcpServerv4OptionValue -ScopeId $scope.ScopeId) }
foreach ($scope in $scopes) { $options+=@(Get-DhcpServerv4OptionValue -ScopeId $scope.ScopeId | ForEach-Object { [pscustomobject]@{ ScopeId=[string]$scope.ScopeId; OptionId=$_.OptionId; Value=$_.Value } }) }
}
return [pscustomobject]@{ Caption=$os.Caption; ProductType=$os.ProductType; PartOfDomain=$computer.PartOfDomain; Adapters=$adapters; Addresses=$addresses; IPInterface=$ipInterface; DnsClient=$dnsClient; OtherAddresses=$others; DefaultRoutes=$routes; Scopes=$scopes; Scopes6=$scopes6; Options=$options; Bindings=$bindings; DhcpInstalled=[bool]$feature.Installed }
}