There appears to be a problem with the file provisioner when the destination path contains spaces. For example the following file provisioner doesn't give me any problems:
{
"type": "file",
"source": "startup.bat",
"destination": "C:\\startup.bat"
}
But the following example does:
{
"type": "file",
"source": "startup.bat",
"destination": "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\startup.bat"
}
Packer won't throw any errors when running the file provisioner, but when I check the destination folder the uploaded file isn't there. I've only tested this behavior for Windows builds, haven't really tried it on Linux.
Try doing
{
"type": "file",
"source": "startup.bat",
"destination": "'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\startup.bat'"
}
Adding the '
might be a workaround
Just tried @pecigonzalo's suggestion, but unfortunately the file still isn't being uploaded.
The error seems to be on https://github.com/packer-community/winrmcp project.
null output will be in this color.
==> null: Waiting for WinRM to become available...
==> null: Connected to WinRM!
==> null: Uploading ../scripts/Write-ZeroesToFreeSpace.ps1 => "C:/tmp dir/Write-ZeroesToFreeSpace.ps1"
==> null: Upload failed: Error restoring file from $env:TEMP\winrmcp-55ee0043-8f52-d008-3693-3d2c56c3747f.tmp to 'C:\tmp dir\Write-ZeroesToFreeSpace.ps1': restore operation returned code=1
Build 'null' errored: Error restoring file from $env:TEMP\winrmcp-55ee0043-8f52-d008-3693-3d2c56c3747f.tmp to 'C:\tmp dir\Write-ZeroesToFreeSpace.ps1': restore operation returned code=1
==> Some builds didn't complete successfully and had errors:
--> null: Error restoring file from $env:TEMP\winrmcp-55ee0043-8f52-d008-3693-3d2c56c3747f.tmp to 'C:\tmp dir\Write-ZeroesToFreeSpace.ps1': restore operation returned code=1
==> Builds finished but no artifacts were created.
was this ever resolved?
Just tried testing in 0.9.0, but I'm still running into the same error.
I am running 0.9.0 as well.
Regards
Steven Wade
Principal Consultant
Steven Wade Consulting Ltd
[email protected]:[email protected]
www.stevenwade.co.ukhttp://www.stevenwade.co.uk
uk.linkedin.com/in/stevendavidwade/http://uk.linkedin.com/in/stevendavidwade/
On 8 Mar 2016, at 21:56, Raznic <[email protected]notifications@github.com> wrote:
Just tried testing in 0.9.0, but I'm still running into the same error.
—
Reply to this email directly or view it on GitHubhttps://github.com/mitchellh/packer/issues/2714#issuecomment-193984783.
I'm seeing this error when uploading a chef/
directory to an AMI that was previously built from packer (tiering AMIs) but not when I create an AMI all in one go.
Through a bunch of research it seems that I was having a race condition.
I was able to resolve my issue by adding a "pause_before": "30s"
to the file
and powershell
provisioner steps that were causing me issues.
Refs: https://github.com/packer-community/packer-windows-plugins/issues/25
FYI, I am having a discussion with the owner of the winrmcp project about a simple fix to resolve this very issue.
Pull Request https://github.com/mitchellh/packer/pull/3488 submitted to fix this issue.
still seeing this in 0.10.1
Confirmed still happening in 0.10.1
So, has anybody found a solution to this?
packer --version
0.10.1
Trying to copy files from my laptop to an Azure VM and it errors out with
==> azure-arm: Waiting for WinRM to become available...
==> azure-arm: Connected to WinRM!
==> azure-arm: Uploading c:\dev\packer\vagrant\packer-azure/PSWindowsUpdate => C:\Program Files\WindowsPowerShell\Module
s\PSWindowsUpdate
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...
==> azure-arm: Resource group has been deleted.
Build 'azure-arm' errored: Error restoring file from $env:TEMP\winrmcp-5769e8e8-b22f-db59-9024-a3e23279449e.tmp to 'C:\P
rogram Files\WindowsPowerShell\Modules\PSWindowsUpdate\Add-WUOfflineSync.ps1': restore operation returned code=1
==> Some builds didn't complete successfully and had errors:
--> azure-arm: Error restoring file from $env:TEMP\winrmcp-5769e8e8-b22f-db59-9024-a3e23279449e.tmp to 'C:\Program Files
\WindowsPowerShell\Modules\PSWindowsUpdate\Add-WUOfflineSync.ps1': restore operation returned code=1
==> Builds finished but no artifacts were created.
Part of my json:
"provisioners": [
{
"type": "file",
"source": "{{template_dir}}/PSWindowsUpdate",
"destination": "C:\\Program Files\\WindowsPowerShell\\Modules\\PSWindowsUpdate"
},
Kind of don't want to go via Storage Accounts on Azure, I'm already doing this on AWS with S3 and it's sort of painful.
What happens when you add pause_before
on the first command after WinRM is available?
@yyolk no change:
==> azure-arm: Waiting for WinRM to become available...
==> azure-arm: Connected to WinRM!
==> azure-arm: Pausing 30s before the next provisioner...
==> azure-arm: Uploading c:\dev\packer\vagrant\packer-azure/PSWindowsUpdate => C:\Program Files\WindowsPowerShell\Module
s\PSWindowsUpdate
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...
==> azure-arm: Resource group has been deleted.
Build 'azure-arm' errored: Error restoring file from $env:TEMP\winrmcp-576a0922-8456-b2c6-db77-c07880045104.tmp to 'C:\P
rogram Files\WindowsPowerShell\Modules\PSWindowsUpdate\Add-WUOfflineSync.ps1': restore operation returned code=1
==> Some builds didn't complete successfully and had errors:
--> azure-arm: Error restoring file from $env:TEMP\winrmcp-576a0922-8456-b2c6-db77-c07880045104.tmp to 'C:\Program Files
\WindowsPowerShell\Modules\PSWindowsUpdate\Add-WUOfflineSync.ps1': restore operation returned code=1
==> Builds finished but no artifacts were created.
It connects to WinRM, but then fails.
Thanks @davidobrien1985 for checking on that, it's worked for me with another WinRM + packer issue and was hoping it would work for you
Fyi @davidobrien1985 I have a packer fork at https://github.com/jamiemjennings/packer which resolves this issue using the patch implemented by @kopaka mentioned above. Unfortunately the official packer project hasn't been able to include the patched version of winrmcp
due to unrelated issues.
Even if the destination path doesn't contain spaces this issue still happens as long as at least one copied file contains a space. For example with this config (which doesn't have spaces):
{
"type": "file",
"source": "{{user `tools_path`}}/",
"destination": "C:\\Tools"
}
Build fails on file with a space:
==> virtualbox-iso: Uploading /home/olivier/opt/malboxes-tools/ => C:\Tools
[...]
Build 'virtualbox-iso' errored: Error restoring file from $env:TEMP\winrmcp-57976d77-c664-49bd-14ed-dd28996a28c2.tmp to 'C:\Tools\ExeinfoPe\skins\Skin - blue deep water.jpg': restore operation returned code=1
Can confirm I'm still seeing this as well.
Packer v0.10.1
[18:20:38] 1469668838,,ui,error,==> amazon-ebs: Upload failed: Error restoring file from $env:TEMP\winrmcp-57995de3-66db-74b2-d3c2-3cfc8a14b498.tmp to 'C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js': restore operation returned code=1
Same story here :-(
==> amazon-ebs: Uploading grid.cmd => C:\ProgramData\grid.cmd
==> amazon-ebs: Uploading grid.cmd => C:\ProgramData\Microsoft\grid.cmd
==> amazon-ebs: Uploading grid.cmd => C:\ProgramData\Microsoft\Windows\grid.cmd
==> amazon-ebs: Uploading grid.cmd => C:\ProgramData\Microsoft\Windows\Start Menu\grid.cmd
==> amazon-ebs: Upload failed: Error restoring file from $env:TEMP\winrmcp-57ab961f-c1c9-2bc2-3bc0-93ad1204133d.tmp to 'C:\ProgramData\Microsoft\Windows\Start Menu\grid.cmd': restore operation returned code=1
Per https://www.packer.io/docs/provisioners/file.html:
"The recommended usage of the file provisioner is to use it to upload files, and then use shell provisioner to move them to the proper place, set permissions, etc."
ie
{
"type": "file",
"source": "files/config.xml",
"destination": "C:\temp\config.xml"
},
{
"type": "powershell",
"inline": [ "move c:\temp\config.xml 'C:\Program Files\Amazon\Ec2ConfigService\settings\config.xml'" ]
}
Any update on this defect? or have you guys figure out any workaround?
Upload to a directory without a space then move it from there.
We updated winrmcp in https://github.com/mitchellh/packer/pull/4424
Verified that this is fixed with
"provisioners": [
{
"type": "file",
"source": "files/myfile",
"destination": "C:\\my file upload"
},
{
"type": "powershell",
"inline": ["dir c:\\"]
}
],
Spaces in paths can be fixed by surrounding the path with double quotes.
"provisioners": [
{
"type": "file",
"source": "files/myfile",
"destination": "\"C:\\my file upload\""
}
],
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.
Most helpful comment
Pull Request https://github.com/mitchellh/packer/pull/3488 submitted to fix this issue.