transferring files from a Windows VM

136 views
Skip to first unread message

Jon Hittner

unread,
Sep 6, 2016, 9:51:00 AM9/6/16
to Packer
Hi-
   We have a need to copy some logs created during the provisioning off the VMs after they are created.   We solved the problem with linux using the file provisioner, but when we attempt to dod the transfer against windows like so:

    {

      "type": "file",

      "direction": "download",

      "source": "C:/install-report.yml",

      "only": ["virtualbox-iso"],

      "destination": "/corp/tc/reports/{{ user `vm_name` }}-v{{ user `version` }}.yml"

    }


we get:

==> virtualbox-iso: Downloading C:/install-report.yml => /corp/tc/reports/eval_windows_2012_r2-v1472874940.yml

==> virtualbox-iso: Download failed: WinRM doesn't support download.


Is this a limitation of WinRM?  Is there any other ways to transfer files off the windows machines at the end of the provisioning stage?


-Jon

Jon Hittner

unread,
Sep 7, 2016, 3:20:49 PM9/7/16
to Packer
After some looking into this issue, I found that although the file upload provisioner does not support downloading with WinRM, WinRM itself does indeed support it.    I guess my best option would be to write my own script to use winrm and call it via local shell provisioner.  Is this the best way to do this?    

Can anyone well me how to send my script the value of winrm_host and winrm_port?   Right now I allow packer to autoconfigure these values and if there is a  {{.Variable}} I can use, I can't figure out what it is.

Thanks

Malte Witt

unread,
Sep 9, 2016, 5:51:44 AM9/9/16
to Packer
I am facing the exact same issue right now trying to download a file, using WinRM communicator.

I had no luck using local shell provisioner on windows in the past, so if you figure out a way to work around this issue, please share your solution here :-)

Thanks,
Malte

Jon Hittner

unread,
Sep 14, 2016, 11:47:32 AM9/14/16
to Packer
yah.. What I finally ended up doing was writing a script to winrm the files from the new VM and calling that from the local-shell provisioner.  Unfortunately I was not able to find a way to pass the vagrant NAT port to the local-shell provisioner so I had hardcode the port (setting ssh_host_port_min and ssh_host_port_max to the value, so I am no longer able to build more then one host at a time using the same template, but I can live with that

Alvaro Miranda Aguilera

unread,
Sep 14, 2016, 12:33:30 PM9/14/16
to packe...@googlegroups.com
if you are using Virtualbox, and you have virtualbox guest additions, you can use the shared folder to move files host <-> guest

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/18ad8acd-b6f3-4179-8a6c-598bf1474d84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages