Has anyone used the linux subsystem in Windows to run packer?

130 views
Skip to first unread message

Johnny Bloom

unread,
Mar 28, 2018, 11:26:40 AM3/28/18
to Packer
I am trying to build a centos7 image in Azure. I wanted to do so from my Windows machine so I tried to use the linux subsystem to do the ssh scp file copy. It keeps erroring with a broken pipe error:

Here is the provisioning step it fails on:
{
    "type": "shell",
    "script": "scripts/bootstrap.sh",
    "execute_command": "{{ .Vars }} sudo -E -S sh {{ .Path }}"
  },

Here is the output:

2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] Opening new ssh session
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] starting remote command: test -d "/tmp/script_8567.sh"
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [ERROR] Remote command exited with '1': test -d "/tmp/script_8567.sh"
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] Opening new ssh session
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] Starting remote scp process:  scp -vt /tmp
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] Started SCP session, beginning transfers...
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] scp: Uploading script_8567.sh: perms=C0777 size=134
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] SCP session complete, closing stdin pipe.
2018/03/27 20:21:56 packer: 2018/03/27 20:21:56 [DEBUG] Waiting for SSH session to complete.
2018/03/27 20:21:57 packer: 2018/03/27 20:21:57 [DEBUG] non-zero exit status: 1
2018/03/27 20:21:57 packer: 2018/03/27 20:21:57 [DEBUG] scp output:  ╔scp: Broken pipe
2018/03/27 20:21:57 packer: 2018/03/27 20:21:57 Retryable error: Error uploading script: Process exited with status 1
2018/03/27 20:21:59 packer: 2018/03/27 20:21:59 [INFO] 129 bytes written for 'uploadData'
2018/03/27 20:21:59 [INFO] 129 bytes written for 'uploadData'

I dont know if this is even possible but I have done lots of things from the Linux Subsytem in Windows so it seemed like it should work.

Curiously I get the same error in powershell running (obviously) on Windows

2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] Opening new ssh session
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] Starting remote scp process:  scp -vt /tmp
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] Started SCP session, beginning transfers...
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] scp: Uploading script_5049.sh: perms=C0666 size=134
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] SCP session complete, closing stdin pipe.
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] Waiting for SSH session to complete.
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] non-zero exit status: 1
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 [DEBUG] scp output:  scp: Broken pipe
2018/03/27 20:44:14 packer.exe: 2018/03/27 20:44:14 Retryable error: Error uploading script: Process exited with status 1
2018/03/27 20:44:16 packer.exe: 2018/03/27 20:44:16 [INFO] 129 bytes written for 'uploadData'
2018/03/27 20:44:16 [INFO] 129 bytes written for 'uploadData'

So it seems like the issue is something outbound that would be similar between the two. I just cant think of what it would be. The packer script works on my coworker's mac so I know it is a problem on my end.

- John

Gabo Kete

unread,
Mar 28, 2018, 4:13:41 PM3/28/18
to Packer
Hi 

Have you tried to upload the script from your windows machine you are running packer , via scp  to azure? looks to me that you have some kind of firewall blocking your ssh/scp connections 

something like scp -vvv /path/to/script.sh <AZURE_HOST>

Trying to upload the script using scp potentially can confirm this.. also will recommend to check the windows event logs

Not a windows expert here, but I found this link that tells you how to enable the firewall logs if this is blocking your connections,

Reply all
Reply to author
Forward
0 new messages