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

Uploading large file and directories using SSH communicator to create Azure Windows Image #288

Open
hc-github-team-packer opened this issue Apr 7, 2023 · 0 comments

Comments

@hc-github-team-packer
Copy link

This issue was originally opened by @Zaheerkhan999 in hashicorp/packer#12284 and has been migrated to this repository. The original issue description is below.


Hi,

I am creating an image with file folders to be uploaded into the Azure windows image.

What I have done so far. I have created a custom windows image with SSH server installed and running the below packer script to provision a new image from that custom image. Packer is able to create all the required resources at runtime but not able to upload any files to it and terminates with the error "Context deadline exceeded".
The same is achievable from winrm but failing with SSH.
Since the files and directories are huge in size so it is taking a lot of time to transfer using winrm that's why I chose SSH communicator to quicky upload the files but its failing.

########################################################################
source "azure-arm" "autogenerated_1" {
azure_tags = {
dept = "Engineering"
task = "Image deployment"
}
build_resource_group_name = "TEST-RG"
client_id = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
communicator = "ssh"
custom_managed_image_name = "SSH-WindowsImage"
custom_managed_image_resource_group_name = "TEST-RG"
managed_image_name = "Windows-image"
managed_image_resource_group_name = "TEST-RG"
os_type = "Windows"
subscription_id = "XXXXXXXXXXXXXXXXXXXXX"
tenant_id = "XXXXXXXXXXXXXXXXXXXXX"
vm_size = "Standard_D2_v2"
ssh_username = "userzktest1"
ssh_password = "PassPktest@123!"
ssh_port = 22
pause_before_connecting = "5m"
ssh_file_transfer_method = "sftp"

}

build {
sources = ["source.azure-arm.autogenerated_1"]

provisioner "file" {
source = "files/bin.zip"
destination = "C:/code/bin.zip"

}

provisioner "powershell" {
inline = ["while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }", "while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }", "& $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 } }"]
}

}
###############################################################################

Any help will be highly appreciated.

Thanks in advance.

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

No branches or pull requests

1 participant