winget provisioner
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.
#### Description
I would like for there to exist a winget provisioner for Packer.
#### Use Case(s)
Instead of using PowerShell provisioner or ansible provisioner to configure the software installed on a Windows VM.
- Using the PowerShell provisioner requires writing (and testing) one
- Using the Ansible provisioner requires configuring winrm in questionable ways
#### Potential configuration
Instead of this:
```json
"provisioners": [
{ "type": "powershell",
"inline": ["Set-ExecutionPolicy Bypass -Scope Process -Force"]
},
{
"type": "powershell",
"script": "ConfigureRemotingForAnsible.ps1"
},
{
"type": "ansible",
"playbook_file": "playbook.yml",
"use_proxy": false,
"user": "packer",
"extra_arguments": ["-vvvv",
"-e", "ansible_winrm_server_cert_validation=ignore"]
},
{
"type": "powershell",
"inline": [
"Set-Service RdAgent -StartupType Disabled",
"Set-Service WindowsAzureGuestAgent -StartupType Disabled",
"Remove-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\SysPrepExternal\\Generalize' -Name '*'"
]
},
{
"type": "windows-restart",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"inline": [
"& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
"while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }"
]
}
]
```
Please may I have this?
```json
"provisioners": [
{ "type": "powershell",
"inline": ["Set-ExecutionPolicy Bypass -Scope Process -Force"]
},
{
"type": "winget",
"import_file": "manifest.json",
"extra_arguments": ["--accept-source-agreements", "--accept-package-agreements"]
},
{
"type": "powershell",
"inline": [
"Set-Service RdAgent -StartupType Disabled",
"Set-Service WindowsAzureGuestAgent -StartupType Disabled",
"Remove-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\SysPrepExternal\\Generalize' -Name '*'"
]
},
{
"type": "windows-restart",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"inline": [
"& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
"while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }"
]
}
]
```
#### Potential References
https://learn.microsoft.com/en-us/windows/package-manager/winget/configure
https://learn.microsoft.com/en-us/windows/package-manager/winget/import
https://learn.microsoft.com/en-us/windows/package-manager/winget/validate
https://learn.microsoft.com/en-us/windows/package-manager/winget/source
Contributor guide
Assessment
This issue has not been assessed yet.