Packer cannot access Windows using WinRM when creating image on Google Compute

2,871 views
Skip to first unread message

Russell Seymour

unread,
Feb 22, 2017, 9:19:58 AM2/22/17
to Packer
Hello,

I am trying to get Packer to build a custom Windows image on GCE.

This is the build section for `googlecompute` in my Packer file:

        {
           
"type": "googlecompute",
           
"account_file": "{{user `gce_account_file`}}",
           
"project_id": "{{user `gce_project_id`}}",
           
"source_image": "{{user `gce_source_image`}}",
           
"zone": "{{user `gce_zone`}}",
           
"disk_type": "pd-ssd",
           
"disk_size": "80",
           
"machine_type": "n1-highcpu-8",
           
"image_name": "workstation-{{user `workstation-number`}}-{{timestamp}}",
           
"communicator": "winrm",
           
"winrm_username": "packer",
           
"winrm_use_ssl": "true",
           
"winrm_insecure": "true",
           
"winrm_port": 5986,
           
"winrm_timeout": "5m"
       
}


The source image is set as `windows-server-2012-r2-dc-v20170117`.

When I attempt to build this machine I get a timeout error for WinRM:

==> googlecompute: Checking image does not exist...
==> googlecompute: Creating temporary SSH key for instance...
==> googlecompute: Using image: windows-server-2012-r2-dc-v20170117
==> googlecompute: Creating instance...
    googlecompute
: Loading zone: europe-west1-b
    googlecompute
: Loading machine type: n1-highcpu-8
    googlecompute
: Loading network: default
    googlecompute
: Requesting instance creation...
    googlecompute
: Waiting for creation operation to complete...
    googlecompute
: Instance has been created!
==> googlecompute: Creating windows user for instance...
    googlecompute
: Waiting for windows password to complete...
    googlecompute
: Created password.
==> googlecompute: Waiting for the instance to become running...
    googlecompute
: IP: 146.148.18.82
==> googlecompute: Waiting for WinRM to become available...
==> googlecompute: Timeout waiting for WinRM.
==> googlecompute: Deleting instance...
    googlecompute
: Instance has been deleted!
==> googlecompute: Deleting disk...
    googlecompute
: Disk has been deleted!
Build 'googlecompute' errored: Timeout waiting for WinRM.


Reading around this I have seen that the Windows user only seems to get created from the Console or the command line using `gcloud`.  If this is the case is it possible to get Packer to create and configure a Windows machine in GCE?  If it is possible to get Packer to build a Windows machine in GCE what am I missing?

Thanks, Russell

Rickard von Essen

unread,
Feb 22, 2017, 10:33:07 AM2/22/17
to packe...@googlegroups.com
I think you might be missing to allow the firewall traffic on port: tcp/5986 from anywhere. By default it allows SSH and RDP but not WinRM. Except for that everything looks fine with me. The user should be created and the password is retrieved over the API in the same way as the gcloud tool do.


--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/5a36c410-99e8-4def-acae-8c606bed0003%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rickard von Essen

unread,
Mar 25, 2017, 12:12:19 PM3/25/17
to packe...@googlegroups.com
Did you get this to work for you?

// Rickard

On 22 February 2017 at 16:32, Rickard von Essen <rickard....@gmail.com> wrote:
I think you might be missing to allow the firewall traffic on port: tcp/5986 from anywhere. By default it allows SSH and RDP but not WinRM. Except for that everything looks fine with me. The user should be created and the password is retrieved over the API in the same way as the gcloud tool do.

Benjamin Lau

unread,
Jul 31, 2017, 4:27:37 PM7/31/17
to Packer
I realize this thread is old... but since I was having the exact same problem I figured I'd report that this DID work for me. :-)

I created a new firewall rule for my packer instances and assigned the rule to apply to my hosts which are tagged "packer" by adding:
    "tags": ["packer"]
to my builders.

Cheers,
Ben


On Saturday, March 25, 2017 at 9:12:19 AM UTC-7, Rickard von Essen wrote:
Did you get this to work for you?

// Rickard
On 22 February 2017 at 16:32, Rickard von Essen <rickard....@gmail.com> wrote:
I think you might be missing to allow the firewall traffic on port: tcp/5986 from anywhere. By default it allows SSH and RDP but not WinRM. Except for that everything looks fine with me. The user should be created and the password is retrieved over the API in the same way as the gcloud tool do.

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages