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

Add skip_build_key_vault_create to skip build Keyvault create during window builds #393

Merged
merged 12 commits into from
May 22, 2024

Conversation

garimakhulbe02
Copy link
Contributor

This PR is add this attribute #357

New attribute/input skip_build_key_vault_create in packer config to skip Keyvault deployment during packer build for windows images. Packer does two ARM deployments during build. First deployment for Keyvault to save WinRM certificate and second deployment for build VM. This attribute will give an option to skip this build Keyvault deployment during build.

@garimakhulbe02 garimakhulbe02 requested a review from a team as a code owner March 19, 2024 18:56
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 19, 2024

CLA assistant check
All committers have signed the CLA.

@garimakhulbe02
Copy link
Contributor Author

@JenGoldstrich @nywilken please take a look. thank you.

@JenGoldstrich
Copy link
Contributor

Hey @garimakhulbe02 thanks for opening this PR, can you post the custom_script and user_data example to load the WinRM certificate that you mentioned in the issue, would be helpful so that I can quickly test this feature, and also add to document how to use this feature, as the new field won't work otherwise as I understand it

@garimakhulbe02
Copy link
Contributor Author

@JenGoldstrich updated PR with example. please take a look. thanks.

@JenGoldstrich
Copy link
Contributor

JenGoldstrich commented Apr 12, 2024

Hey @garimakhulbe02 I emailed you too but just to have the context here for any other contributors or readers I am running into the following error

```WinRM firewall exception will not work since one of the network \r\nconnection types on this machine is set to Public. Change the network connection type to either Domain or Private and \r\ntry again. 

from the VM extension when trying to deploy the VM template
with the provided configuration, can you provide me the template you use to build this feature so I can see what network config I'm missing to make this work

@garimakhulbe02
Copy link
Contributor Author

Hey @garimakhulbe02 I emailed you too but just to have the context here for any other contributors or readers I am running into the following error

```WinRM firewall exception will not work since one of the network \r\nconnection types on this machine is set to Public. Change the network connection type to either Domain or Private and \r\ntry again. 

from the VM extension when trying to deploy the VM template with the provided configuration, can you provide me the template you use to build this feature so I can see what network config I'm missing to make this work

let me check. will send you by tomorrow EOD.

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few suggestions mostly on the docs, but overall this LGTM!

builder/azure/arm/config.go Outdated Show resolved Hide resolved
builder/azure/arm/config.go Outdated Show resolved Hide resolved
builder/azure/arm/config.go Outdated Show resolved Hide resolved
example/windows_skip_key_vault/11/userdata.ps1 Outdated Show resolved Hide resolved
New-NetFirewallRule -Name "Allow WinRM HTTPS" -DisplayName "WinRM HTTPS" -Enabled True -Profile Any -Action Allow -Direction Inbound -LocalPort 5986 -Protocol TCP

# Used for creating the WinRM certificate for authentication
$thumbprint = (New-SelfSignedCertificate -DnsName $env:COMPUTERNAME -CertStoreLocation Cert:\LocalMachine\My -NotAfter $(Get-Date).AddDays(1)).Thumbprint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm not sure of, how does the certificate get passed along to the plugin if it's used for authentication? Unless I'm mistaken this script executes early on the Windows instance, before we can connect to the instance itself, so how do we get this?
Or is the certificate only so HTTPS can be used for the connection?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is only so HTTPS can be used for the certificate, you can't create a WinRM HTTPS listener without a certificate, I do not believe the certificate is given to the user

builder/azure/arm/config.go Show resolved Hide resolved
JenGoldstrich and others added 4 commits May 22, 2024 08:17
Co-authored-by: Lucas Bajolet <105649352+lbajolet-hashicorp@users.noreply.github.com>
Co-authored-by: Lucas Bajolet <105649352+lbajolet-hashicorp@users.noreply.github.com>
@JenGoldstrich JenGoldstrich merged commit 04e2be0 into hashicorp:main May 22, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants