[Windows AWS CI] Set default profile for AWS instances
Categories
(Infrastructure & Operations :: RelOps: Windows OS, task)
Tracking
(Not tracked)
People
(Reporter: markco, Assigned: markco)
References
Details
Currently in https://github.com/mozilla-releng/OpenCloudConfig/blob/master/userdata/OCC-Bootstrap.psm1
function Set-DefaultProfileProperties {
param (
[string] $path = 'C:\Users\Default\NTUSER.DAT',
[object[]] $entries = @(
New-Object PSObject -Property @{
Key = 'Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects';
ValueName = 'VisualFXSetting';
ValueType = 'DWord';
ValueData = 1
}
)
)
begin {
Write-Log -message ('{0} :: begin - {1:o}' -f $($MyInvocation.MyCommand.Name), (Get-Date).ToUniversalTime()) -severity 'DEBUG'
}
process {
try {
Import-RegistryHive -File $path -Key 'HKLM\TEMP_HIVE' -Name TempHive
foreach ($entry in $entries) {
if (-not (Test-Path -Path ('TempHive:{0}' -f $entry.Key) -ErrorAction SilentlyContinue)) {
New-Item -Path ('TempHive:{0}' -f $entry.Key) -Force
Write-Log -message ('{0} :: {1} created' -f $($MyInvocation.MyCommand.Name), $entry.Key) -severity 'DEBUG'
}
New-ItemProperty -Path ('TempHive:{0}' -f $entry.Key) -Name $entry.ValueName -PropertyType $entry.ValueType -Value $entry.ValueData
Write-Log -message ('{0} :: {1}{2} set to {3}' -f $($MyInvocation.MyCommand.Name), $entry.Key, $entry.ValueName, $entry.ValueData) -severity 'DEBUG'
}
$attempt = 0 # attempt Remove-RegistryHive up to 3 times
while($attempt -le 3) {
try {
$attempt++
Remove-RegistryHive -Name TempHive
Write-Log -message ('{0} :: temporary hive unloaded' -f $($MyInvocation.MyCommand.Name)) -severity 'DEBUG'
break
}
catch {
if ($attempt -eq 3) {
throw
}
Write-Log -message ('{0} :: temporary hive unload failed. retrying...' -f $($MyInvocation.MyCommand.Name)) -severity 'ERROR'
Start-Sleep -Milliseconds 100
[System.GC]::Collect()
}
}
}
catch {
Write-Log -message ('{0} :: failed to set default profile properties. {1}' -f $($MyInvocation.MyCommand.Name), $_.Exception.Message) -severity 'ERROR'
}
}
end {
Write-Log -message ('{0} :: end - {1:o}' -f $($MyInvocation.MyCommand.Name), (Get-Date).ToUniversalTime()) -severity 'DEBUG'
}
}
Which calls Import-RegistryHive and Remove-RegistryHive ,https://github.com/mozilla-releng/OpenCloudConfig/blob/4d397b22539de38e463dafbf1eca516ed496ff08/userdata/OCC-Bootstrap.psm1#L1114 .
| Assignee | ||
Comment 1•6 years ago
|
||
This should be handled by the CI during build and capture of the golden image.
| Assignee | ||
Comment 2•6 years ago
|
||
At this time Ronin Puppet will not support Windows AWS.
Description
•