I have an issue with building an image in Azure with custom winrm_username and winrm_password.
Below you can find my code:
{ "variables": {
"ssh_user": "Administrator",
"ssh_pass": "!_Qwerty11Qwerty",
"winrm_user": "Administrator",
"winrm_password": "!_Qwerty11Qwerty",
"location": "East US",
"ssh_password":""
}, "builders": [ {
"name": "windows-2019",
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"subscription_id": "{{user `subscription_id`}}",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2019-Datacenter",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_timeout": "3m",
"winrm_username": "{{user `winrm_user`}}",
"winrm_password": "{{user `winrm_password`}}",
"location": "{{user `location`}}",
"vm_size": "Standard_D2_v2", }],
"provisioners": []
}
Instead of specified by me winrm_username and password, in debug mode I can see next: windows-2019 output will be in this color.
==> windows-2019: Running builder ...
==> windows-2019: Getting tokens using client secret
windows-2019: Creating Azure Resource Manager (ARM) client ...
==> windows-2019: WARNING: Zone resiliency may not be supported in East US, checkout the docs at https://docs.microsoft.com/en-us/azure/availability-zones/
windows-2019: temp admin user: 'packer'
windows-2019: temp admin password: 'aMyOIb8UCCCRIClm5IUdIJD5h7XpKQfT'
Packer version: 1.4.4
Could you please let me know, how can I use custom winrm_username and winrm_password in Azure during image building?
Regards, Ihor
Thanks for reaching out. We’ll take a look when we get a chance!
@kanivetsi This seems to be fixed here https://github.com/hashicorp/packer/pull/8670
Could you try to update Packer to its last version, please?
I think you still won't be able to set the username and I'll try to figure out if this is expected behavior or not.
@sylviamoss Thanks for the quick response.
I checked the mentioned code with the latest Packer version (1.5.4), I got output below:
windows-2019: output will be in this color.
windows-2019: output will be in this color.
==> windows-2019: Running builder ...
==> windows-2019: Getting tokens using client secret
==> windows-2019: Getting tokens using client secret
windows-2019: Creating Azure Resource Manager (ARM) client ...
==> windows-2019: WARNING: Zone resiliency may not be supported in East US, checkout the docs at https://docs.microsoft.com/en-us/azure/availability-zones/
windows-2019: temp admin user: 'packer'
windows-2019: temp admin password: 'laKabmqET45DshzrhQw3klVCWxTYDz4X'
==> windows-2019: Creating resource group ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-3m2bmhzlam'
==> windows-2019: -> Location : 'East US'
==> windows-2019: Validating deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-3m2bmhzlam'
==> windows-2019: -> DeploymentName : 'pkrdp3m2bmhzlam'
==> windows-2019: Deploying deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-3m2bmhzlam'
==> windows-2019: -> DeploymentName : 'kvpkrdp3m2bmhzlam'
==> windows-2019: Getting the certificate's URL ...
==> windows-2019: -> Key Vault Name : 'pkrkv3m2bmhzlam'
==> windows-2019: -> Key Vault Secret Name : 'packerKeyVaultSecret'
==> windows-2019: -> Certificate URL : 'https://pkrkv3m2bmhzlam.vault.azure.net/secrets/packerKeyVaultSecret/55a251ba2f4c4cd3adfd089aa85bce05'
==> windows-2019: Setting the certificate's URL ...
==> windows-2019: Validating deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-3m2bmhzlam'
==> windows-2019: -> DeploymentName : 'pkrdp3m2bmhzlam'
==> windows-2019: Deploying deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-3m2bmhzlam'
==> windows-2019: -> DeploymentName : 'pkrdp3m2bmhzlam'
==> windows-2019: Getting the VM's IP address ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-3m2bmhzlam'
==> windows-2019: -> PublicIPAddressName : 'pkrip3m2bmhzlam'
==> windows-2019: -> NicName : 'pkrni3m2bmhzlam'
==> windows-2019: -> Network Connection : 'PublicEndpoint'
==> windows-2019: -> IP Address : '13.92.255.135'
==> windows-2019: Waiting for WinRM to become available...
==> windows-2019: Timeout waiting for WinRM.
==> windows-2019: Timeout waiting for WinRM.
==> windows-2019: Step "StepConnectWinRM" failed, aborting...
==> windows-2019: aborted: skipping cleanup of step "StepGetIPAddress"
==> windows-2019: aborted: skipping cleanup of step "StepDeployTemplate"
==> windows-2019: aborted: skipping cleanup of step "StepValidateTemplate"
==> windows-2019: aborted: skipping cleanup of step "StepSetCertificate"
==> windows-2019: aborted: skipping cleanup of step "StepGetCertificate"
==> windows-2019: aborted: skipping cleanup of step "StepDeployTemplate"
==> windows-2019: aborted: skipping cleanup of step "StepValidateTemplate"
==> windows-2019: aborted: skipping cleanup of step "StepCreateResourceGroup"
Build 'windows-2019' errored: Timeout waiting for WinRM.
==> Some builds didn't complete successfully and had errors:
--> windows-2019: Timeout waiting for WinRM.
==> Builds finished but no artifacts were created.
With Packer 1.4.4 I had output below:
windows-2019 output will be in this color.
==> windows-2019: Running builder ...
==> windows-2019: Getting tokens using client secret
windows-2019: Creating Azure Resource Manager (ARM) client ...
==> windows-2019: WARNING: Zone resiliency may not be supported in East US, checkout the docs at https://docs.microsoft.com/en-us/azure/availability-zones/
windows-2019: temp admin user: 'packer'
windows-2019: temp admin password: 'q0qn8LU00WoKWGZDYZ7wv0QwjQHUbJhG'
==> windows-2019: Creating resource group ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-fihcjlznxx'
==> windows-2019: -> Location : 'East US'
==> windows-2019: Validating deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-fihcjlznxx'
==> windows-2019: -> DeploymentName : 'pkrdpfihcjlznxx'
==> windows-2019: Deploying deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-fihcjlznxx'
==> windows-2019: -> DeploymentName : 'kvpkrdpfihcjlznxx'
==> windows-2019: Getting the certificate's URL ...
==> windows-2019: -> Key Vault Name : 'pkrkvfihcjlznxx'
==> windows-2019: -> Key Vault Secret Name : 'packerKeyVaultSecret'
==> windows-2019: -> Certificate URL : 'https://pkrkvfihcjlznxx.vault.azure.net/secrets/packerKeyVaultSecret/fb842eee2a174c07b8daa94377b087ca'
==> windows-2019: Setting the certificate's URL ...
==> windows-2019: Validating deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-fihcjlznxx'
==> windows-2019: -> DeploymentName : 'pkrdpfihcjlznxx'
==> windows-2019: Deploying deployment template ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-fihcjlznxx'
==> windows-2019: -> DeploymentName : 'pkrdpfihcjlznxx'
==> windows-2019: Getting the VM's IP address ...
==> windows-2019: -> ResourceGroupName : 'packer-Resource-Group-fihcjlznxx'
==> windows-2019: -> PublicIPAddressName : 'pkripfihcjlznxx'
==> windows-2019: -> NicName : 'pkrnifihcjlznxx'
==> windows-2019: -> Network Connection : 'PublicEndpoint'
==> windows-2019: -> IP Address : '40.71.250.130'
==> windows-2019: Waiting for WinRM to become available...
==> windows-2019: #< CLIXML
windows-2019: WinRM connected.
==> windows-2019: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> windows-2019: Connected to WinRM!
==> windows-2019: Running local shell script: /tmp/packer-shell003224702
windows-2019: Resolving cookbook dependencies...
So based on performed tests I can see, that both Packer versions 1.4.4 and 1.5.4 use temp admin user: 'packer'. But it works with 1.4.4 and doesn't work with Packer 1.5.4 (WinRm timeout).
Please let me know if additional information required from my side.
Regards,
Ihor
@kanivetsi I will dig into this more to find out what's going on! thanks for testing this and sharing the results!
Hey there, @kanivetsi! Check out the solution I've implemented for this. You can use these binaries: https://circleci.com/gh/hashicorp/packer/40938#artifacts/containers/0
Let me know if works as expected :)
hello, @sylviamoss !
Thanks for so quick fix.
I've checked - everything works as expected and I can use custom winrm_username different from the 'packer'.
I downloaded the packer by the link, which you shared with me, and it is Ok.
Regards,
Ihor
Good to know! Thanks again for opening this issue 🎉
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.