Having issue creating vmware windows2012r2 template using static IP

83 views
Skip to first unread message

Shyam J

unread,
Feb 12, 2019, 4:30:34 AM2/12/19
to Packer
Hi,

Requesting help!!
I am trying to create vmware windows2012r2 template in ESXi machine. But Packer stucks at Waiting WinRM. The VM is getting created but mentioned IP is not getting assigned to the VM(attached screenshot) eventhough we can see the network card is connected. PFA JSON and autounattend.xml file along with logs ran in debug mode.

If the method I am following in autounattend.xml is wrong for static IP please mention the required one.

ESXi version: VMware ESXi, 6.0.0, 7967664
Packer version : 1.3.2

Thanks in advance
Shyam
packer error.jpg
logs.txt
autounattend.xml
JSON.txt

Rickard von Essen

unread,
Feb 12, 2019, 6:06:04 AM2/12/19
to packe...@googlegroups.com
If you use a static IP you have to set it in:

1) autounattended.xml so Windows is configured with it. 
2) winrm_host in the packer template 
3) Maybe somewhere in vmx data to ensure that vSphere doesn't assign it some other IP. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/9736f9e9-e4fc-4c15-a78e-d11fe6a1c556%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin DynamicD

unread,
Feb 13, 2019, 4:47:37 PM2/13/19
to Packer
Waiting for WinRM simply means it doesn't see any activity on the IP at port 5985/5986 yet (depending if you set winrm_use_ssl to true or not).

Your problem most likely is that you haven't configured WinRM yet, as that's disabled by default in 2012R2.  In your autounattend.xml you need to include something like:

<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<!-- Enable WinRM service -->
<CommandLine>powershell –NoProfile -File a:\Setup_WinRM.ps1</CommandLine>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>

You can then include that powershell script in the same directory as your autounattend.xml so it gets added to the dynamic A: drive to ensure it runs.  In that script you can setup WinRM with the correct port, transport, etc (or just do a /quickconfig if you prefer).

Shyam J

unread,
Feb 19, 2019, 1:49:07 AM2/19/19
to Packer
Thanks for Checking Justin. I have the below settings in my autounattend.xml file. Do you mean to say winrm still needs to be enabled? I have turned firewall off.

<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
<Description>winrm quickconfig -q</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
<Description>winrm quickconfig -transport:http</Description>
<Order>4</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>
cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
</CommandLine>
<Description>Win RM MaxTimoutms</Description>
<Order>5</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>
cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="800"}
</CommandLine>
<Description>Win RM MaxMemoryPerShellMB</Description>
<Order>6</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>
cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
</CommandLine>
<Description>Win RM AllowUnencrypted</Description>
<Order>7</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>
cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
</CommandLine>
<Description>Win RM auth Basic</Description>
<Order>8</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>
cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
</CommandLine>
<Description>Win RM client auth Basic</Description>
<Order>9</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>
cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
</CommandLine>
<Description>Win RM listener Address/Port</Description>
<Order>10</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>

Thanks
Shyam

Shyam J

unread,
Feb 19, 2019, 3:00:21 AM2/19/19
to Packer
Thanks Rickard for checking. 

1.IP is already mentioned in autounattednd.xml. 
2. Didnt understand about much in details here. This is the explanation in packer website. winrm_host (string) - The address for WinRM to connect to. So here which will be the host and destination?
3. Read in some vmware forums like VMX data cant be read by operating system getting installed in VM. Not sure whether its true. So do you know what parameters we can pass for the same?y

Thanks
Shyam

Shyam J

unread,
Feb 25, 2019, 11:59:08 PM2/25/19
to Packer
Did you get a chance to go through my below comments Rickard?

Thanks
Shyam

Rickard von Essen

unread,
Feb 26, 2019, 12:20:38 AM2/26/19
to packe...@googlegroups.com
Whatever IP is in the autounattended.xml must also be in winrm_host. I can't say much more, haven't used Windows in nearly two decades. 

Shyam J

unread,
Feb 27, 2019, 9:11:29 AM2/27/19
to Packer
I see. I tried configuring winrm_host but didnt help. The given IP is not getting configured in windows VM (screenshot) so may be winrm_host is not going to help. Please keep this case open, I will wait for somebody who has worked on it the same way.

Thanks
Shyam

Shyam J

unread,
Mar 20, 2019, 12:09:05 AM3/20/19
to Packer
Hello All,

Thanks for looking into it. I got it working, so thought to share with you if this is going to help for someone.
I was using wrong <Identifier> name, when used "Ethernet" I got the IP configured. But <NextHopAddress> didnt help with configuring gateway, i had to use a script added to the autounattend.xml like below

cmd.exe /c powershell -File a:\SetGateway.ps1

cat SetGateway.ps1
$nac = get-wmiobject Win32_NetworkAdapterConfiguration
$nac.SetGateways("gateway_IP",1)

This case can be archived.

Thanks
Shyam
Reply all
Reply to author
Forward
0 new messages