Skip to content

Commit

Permalink
- Fixed issue with DscLcmController, The RebootNodeIfNeeded property …
Browse files Browse the repository at this point in the history
…is not set to true when the LCM is already in ApplyAndAutoCorrect mode (#155)

* - Fixed issue with DscLcmController, The RebootNodeIfNeeded property is not
set to true when the LCM is already in ApplyAndAutoCorrect mode

* Fixed GitVersion depreciated version in azurepipeline

* Changed upper to lower case in build.ps1 file name
  • Loading branch information
NicolasBn authored Mar 8, 2022
1 parent eabad05 commit 4c915cc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added remote desktop control to 'ComputerSettings'.
- Fixed an issue with DscLcmController, the RebootNodeIfNeeded property is not
set to false before the first execution of maintenance window.
- Fixed issue with DscLcmController, The RebootNodeIfNeeded property is not
set to true when the LCM is already in ApplyAndAutoCorrect mode.
- Fixed GitVersion depreciated version in azurepipeline.
21 changes: 12 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,27 @@ stages:
- job: Package_Module
displayName: 'Package Module'
pool:
vmImage: 'windows-2019'
vmImage: 'ubuntu-latest'
steps:
- task: GitVersion@5
name: gitVersion
displayName: 'Evaluate Next Version'
inputs:
runtime: 'core'
configFilePath: 'GitVersion.yml'
- pwsh: |
dotnet tool install --global GitVersion.Tool
$gitVersionObject = dotnet-gitversion | ConvertFrom-Json
$gitVersionObject.PSObject.Properties.ForEach{
Write-Host -Object "Setting Task Variable '$($_.Name)' with value '$($_.Value)'."
Write-Host -Object "##vso[task.setvariable variable=$($_.Name);]$($_.Value)"
}
Write-Host -Object "##vso[build.updatebuildnumber]$($gitVersionObject.FullSemVer)"
displayName: Calculate ModuleVersion (GitVersion)
- task: PowerShell@2
name: package
displayName: 'Build & Package Module'
inputs:
filePath: './build.ps1'
arguments: '-ResolveDependency -tasks pack'
pwsh: false
pwsh: true
env:
ModuleVersion: $(gitVersion.NuGetVersionV2)
ModuleVersion: $(NuGetVersionV2)

- task: PublishPipelineArtifact@1
displayName: 'Publish Build Artifact'
Expand Down
File renamed without changes.
21 changes: 5 additions & 16 deletions source/DSCResources/DscLcmController/DscLcmController.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,6 @@ function Set-LcmMode {
$pattern = '(ConfigurationMode(\s+)?=(\s+)?)("\w+")(;)'
$content = $content -replace $pattern, ('$1 "{0}"$5' -f $Mode)
# If mode is ApplyAndMonitor, set to not reboot, if set to ApplyAndAutoCorrect, set to reboot if needed
[bool] $rebootIfNeeded = $True
if ($Mode -eq 'ApplyAndMonitor') {
$rebootIfNeeded = $False
}
else {
$rebootIfNeeded = $True
}
$patternRebootNodeIfNeeded = '(RebootNodeIfNeeded(\s+)?=(\s+)?)(true|false);'
$content = $content -replace $patternRebootNodeIfNeeded, ('$1 {0};' -f $RebootIfNeeded)
$content | Out-File -FilePath $mofFile.FullName -Encoding unicode
Write-Host "LCM RebootIfNeededValue is set to '$rebootIfNeeded'"
Write-Host "LCM put into '$Mode' mode"
}
Expand Down Expand Up @@ -513,6 +497,11 @@ Set-LcmPostpone
$inMaintenanceWindow = Test-InMaintenanceWindow
Write-Host
if ($inMaintenanceWindow) {
if (!$lcmConfiguration.RebootNodeIfNeeded)
{
Write-Host "RebootNodeIfNeeded is set to 'False', but it's in maintenance window, set RebootNodeIfNeeded to 'True'"
Set-LcmRebootNodeIfNeededMode -RebootNodeIfNeeded $true
}
if ($maintenanceWindowMode -eq 'AutoCorrect' -and $currentConfigurationMode -ne 'ApplyAndAutoCorrect') {
Write-Host "MaintenanceWindowMode is '$maintenanceWindowMode' but LCM is set to '$currentConfigurationMode'. Changing LCM to 'ApplyAndAutoCorrect'"
Set-LcmMode -Mode 'ApplyAndAutoCorrect'
Expand Down

0 comments on commit 4c915cc

Please sign in to comment.