winrm communicator in GCE

170 views
Skip to first unread message

sorce...@gmail.com

unread,
Jul 21, 2017, 5:22:44 AM7/21/17
to Packer
I have a trouble with winRM connectivity, my configuration:
{
  "variables": {
  "startup_script": "winrm quickconfig -quiet & net user /add packer & net localgroup administrators packer /add & netsh advfirewall firewall set rule name=\"Windows Remote Management (HTTP-In)\" profile=public new remoteip=any & winrm set winrm/config/service @{AllowUnencrypted=\"true\"} & winrm set winrm/config/service/auth @{Basic=\"true\"} & powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Set-ExecutionPolicy -ExecutionPolicy bypass -Force\""
  },

  "builders": [{
    "type": "googlecompute",
    "account_file": "acc.json",
    "project_id": "test-project",
    "source_image": "windows-server-2016-dc-v20170711",
    "disk_size": "50",
    "machine_type": "n1-standard-1",
    "zone": "us-central1-a",
    "network": "default",
    "subnetwork": "default",
    "omit_external_ip": true,
    "use_internal_ip": true,
    "instance_name": "win-base",
    "communicator": "winrm",
    "winrm_username": "packer",
    "winrm_insecure": true,
    "winrm_timeout": "3m",
    "winrm_use_ssl": false,
    "metadata": { "windows-startup-script-cmd": "{{user `startup_script`}}" }
  }],
 "provisioners": [{
    "type": "powershell",
    "inline": [
      "dir c:\\"
    ]
  }]
}

in logs:

2017/07/21 09:13:20 packer: 2017/07/21 09:13:20 [INFO] Attempting WinRM connection...
2017/07/21 09:13:20 packer: 2017/07/21 09:13:20 [DEBUG] connecting to remote shell using WinRM
2017/07/21 09:13:20 packer: 2017/07/21 09:13:20 [ERROR] connection error: http response error: 401 - invalid content type
2017/07/21 09:13:20 packer: 2017/07/21 09:13:20 [ERROR] WinRM connection err: http response error: 401 - invalid content type

when i'm trying to use "winrm_use_ssl": true, i recive trouble with i/o timeout.

But more interesting fact was вiscovered on page https://www.packer.io/docs/provisioners/powershell.html:
"The PowerShell Packer provisioner runs PowerShell scripts on Windows machines. It assumes that the communicator in use is WinRM."
Which means: if i haven't ready-to-use WinRM - i haven't any provisioning.

Could anybody look at the issue?

Alvaro Miranda Aguilera

unread,
Jul 21, 2017, 6:26:51 AM7/21/17
to packe...@googlegroups.com
so, did you check this thread?



is the firewall open?

where you are running packer need to be able to reach that vm on the winrm port

Virusvrij. www.avast.com

--
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/8f64ef54-f559-4527-a9cb-8c32028041f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

sorce...@gmail.com

unread,
Jul 21, 2017, 9:12:59 AM7/21/17
to Packer
yep, saw that. it doesn't work for some reason.
Actuay, i don't care about ssl in winRM session, but 401 is really strange response..

Alvaro Miranda Aguilera:
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Jul 21, 2017, 9:22:35 AM7/21/17
to packe...@googlegroups.com
So, seems the 401 cames because Auth basic is not enabled.

Can you confirm that got applied?


There are the commands that should make it work:
winrm set winrm/config/service/Auth '@{Basic="true"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}'

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/588c1f51-2e20-4a78-9ff8-4135d9ccbb94%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Rickard von Essen

unread,
Jul 21, 2017, 3:28:40 PM7/21/17
to packe...@googlegroups.com
Added ing a working example for HTTPS for reference:

{
  "variables": {
  "startup_script": "winrm quickconfig -quiet & net user /add packer & net localgroup administrators packer /add & winrm set winrm/config/service/auth @{Basic=\"true\"}"
  },

  "builders": [{
    "type": "googlecompute",
    "project_id": "packer-test-141600",
    "source_image": "windows-server-2016-dc-v20170711",
    "disk_size": "50",
    "machine_type": "n1-standard-1",
    "zone": "europe-west1-b",
    "network": "default",
    "subnetwork": "default",
    "communicator": "winrm",
    "winrm_username": "packer",
    "winrm_insecure": true,
    "winrm_timeout": "30m",
    "winrm_use_ssl": true,
    "metadata": { "windows-startup-script-cmd": "{{user `startup_script`}}" }
  }],
 "provisioners": [{
    "type": "powershell",
    "inline": [
      "dir c:\\"
    ]
  }]
}

sorce...@gmail.com

unread,
Jul 24, 2017, 6:56:12 AM7/24/17
to Packer
Rickard, i took your config and still have:

2017/07/24 10:49:51 packer: 2017/07/24 10:49:51 [DEBUG] connecting to remote shell using WinRM
2017/07/24 10:50:21 packer: 2017/07/24 10:50:21 [ERROR] connection error: unknown error Post https://10.132.0.2:5986/wsman: dial tcp 10.132.0.2:5986: i/o timeout
2017/07/24 10:50:21 packer: 2017/07/24 10:50:21 [ERROR] WinRM connection err: unknown error Post https://10.132.0.2:5986/wsman: dial tcp 10.132.0.2:5986: i/o timeout
2017/07/24 10:50:26 packer: 2017/07/24 10:50:26 [INFO] Attempting WinRM connection...
2017/07/24 10:50:26 packer: 2017/07/24 10:50:26 [DEBUG] connecting to remote shell using WinRM
2017/07/24 10:50:56 packer: 2017/07/24 10:50:56 [ERROR] connection error: unknown error Post https://10.132.0.2:5986/wsman: dial tcp 10.132.0.2:5986: i/o timeout
2017/07/24 10:50:56 packer: 2017/07/24 10:50:56 [ERROR] WinRM connection err: unknown error Post https://10.132.0.2:5986/wsman: dial tcp 10.132.0.2:5986: i/o timeout
2017/07/24 10:51:01 packer: 2017/07/24 10:51:01 [INFO] Attempting WinRM connection...
2017/07/24 10:51:01 packer: 2017/07/24 10:51:01 [DEBUG] connecting to remote shell using WinRM
2017/07/24 10:51:02 packer: 2017/07/24 10:51:02 [ERROR] connection error: http response error: 401 - invalid content type
2017/07/24 10:51:02 packer: 2017/07/24 10:51:02 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2017/07/24 10:51:07 packer: 2017/07/24 10:51:07 [INFO] Attempting WinRM connection...
2017/07/24 10:51:07 packer: 2017/07/24 10:51:07 [DEBUG] connecting to remote shell using WinRM
2017/07/24 10:51:08 packer: 2017/07/24 10:51:08 [ERROR] connection error: http response error: 401 - invalid content type
2017/07/24 10:51:08 packer: 2017/07/24 10:51:08 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2017/07/24 10:51:13 packer: 2017/07/24 10:51:13 [INFO] Attempting WinRM connection...
2017/07/24 10:51:13 packer: 2017/07/24 10:51:13 [DEBUG] connecting to remote shell using WinRM
2017/07/24 10:51:15 packer: 2017/07/24 10:51:15 [ERROR] connection error: http response error: 401 - invalid content type
2017/07/24 10:51:15 packer: 2017/07/24 10:51:15 [ERROR] WinRM connection err: http response error: 401 - invalid content type

only "project_id" and "account_file" was changed...

Rickard von Essen:



--
Alvaro

--
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.

sorce...@gmail.com

unread,
Jul 24, 2017, 7:13:13 AM7/24/17
to Packer
OHHHH! it works.
I shuld have much more patience!
Thanks for help!

Rickard von Essen

unread,
Jul 24, 2017, 7:27:30 AM7/24/17
to packe...@googlegroups.com
Yeah, Windows is sloooow... 

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/ed2f7291-6793-4f7f-adee-cc28f9b61a51%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages