Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winget provisioner #12503

Open
ncook-hxgn opened this issue Jul 14, 2023 · 0 comments
Open

winget provisioner #12503

ncook-hxgn opened this issue Jul 14, 2023 · 0 comments

Comments

@ncook-hxgn
Copy link

ncook-hxgn commented Jul 14, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction 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:

    "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?

    "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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant