来自MSDN
RebootNodeIfNeeded :目标节点上的某些configuration更改可能需要重新启动才能应用更改。 如果值为“true”,则此属性将立即重新启动节点,而不会发出警告。 如果“false”,则configuration将完成,但必须手动重新启动节点才能使更改生效。
所以我的理解是即使需要重新启动,DSC也应该运行所有的configuration
但在我的情况是这样的,安装一个软件包后,有时DSC被标记为重新启动,DSC不运行其余的configuration
我必须再次手动执行该命令才能运行其余的configuration
Start-DscConfiguration -Wait -Force -Path .\SomePath
我想迫使DSC运行所有configuration,然后通知我是否需要重新启动服务器
我如何configuration软件包的例子
LocalConfigurationManager { RebootNodeIfNeeded = $false } Package MVC3 { Name = "Microsoft ASP.NET MVC 3" Ensure = "Present" Path = "$Env:SystemDrive\AspNetMVC3ToolsUpdateSetup.exe" ProductId = "DCDEC776-BADD-48B9-8F9A-DFF513C3D7FA" Arguments = "/q" DependsOn = "[WindowsFeature]IIS" Credential = $Credential } Package MVC4 { Name = "Microsoft ASP.NET MVC 4 Runtime" Ensure = "Present" Path = "$Env:SystemDrive\AspNetMVC4Setup.exe" ProductId = "942CC691-5B98-42A3-8BC5-A246BA69D983" Arguments = "/q" DependsOn = "[Package]MVC3" Credential = $Credential }
我想出了这个解决scheme
我想找一个更好的方法来做到这一点。 但无论如何它适用于我
我仍然相信DSC过程应该以某种方式通知我,而不仅仅是通过Write-Verbose,因为在我的情况下,这个过程作为我们持续集成过程的一部分被启动
[int]$maximumAttempts = 5 [int]$attempt = 0 [ValidateNotNull()][guid]$dscResTmp = [guid]::NewGuid() [ValidateNotNullOrEmpty()][string]$dscResPathTmp = Join-Path $baseFolderPathTmp "$dscResTmp.log" do { [bool]$stopLoop = $false [int]$attempt = ++$attempt Start-DscConfiguration -Wait -Force -Path $folderPathTmp 4> $dscResPathTmp [string[]]$rebootServerCoincidences = Select-String -Pattern "reboot" -Path $dscResPathTmp if ($rebootServerCoincidences.Length -le 0) { [bool]$stopLoop = $true } else { Write-Warning ($rebootServerCoincidences -join [Environment]::NewLine) } } while($stopLoop -eq $false -and $attempt -le $maximumAttempts) if ($stopLoop -eq $false) { Write-Warning "Max attempts reached" }
每个资源都可以请求LCM重新启动服务器。 如果某个资源请求重新引导,它将安排重新引导,并在服务器重新引导之后安排LCM运行一致性检查(因此它可以继续configuration)。
如果要通知您(通过事件日志或Start-DscConfiguration的详细stream)需要重新引导,则需要将RebootIfNeeded设置为$ false。 那么你有责任重新启动。 如果机器需要重新启动,某些安装程序将不会运行,因此这可能是一个阻止程序,等待您手动重新引导系统。