Post-Processor Local-Shell

375 views
Skip to first unread message

James Elmes

unread,
Jul 4, 2017, 6:46:24 PM7/4/17
to Packer
Hi I am trying to export my final artifact (VMX file on a remote esxi host) to an OVA, this command works if i populate variables manually.

Please see my Template and variables attached.

this command works fine:
ovftool -tt=ova vi://root:pass...@10.1.1.15/Windows2012R2v4-2017-06 ovaexport.ova

this doesn't:
  "post-processors": [
    {
    "type":"shell-local",
    "inline":"ovftool/ovftool -tt=ova vi://{{user `esxi_username`}}:{{user `esxi_password`}}@{{user `esxi_host`}}/{{ .Name }} ovaexport1.ova"

IF anyone has managed to pass these variables through successfully or can see what i am doing wrong that would be great if you could help..

James
packertemplate.json
esx_variables.json

James Elmes

unread,
Jul 5, 2017, 12:59:19 AM7/5/17
to Packer
Even when I insert the command as below it still fails, but if i run it from CMD locally its fine

  "post-processors": [
    {
    "type":"shell-local",
    "inline":"ovftool -tt=ova vi://root:pass...@10.1.1.15/Windows2012R2v1-2017-07 ovaexport1111.ova"
    }

==> Windows2012R2v1-2017-07: Running post-processor: shell-local
==> Windows2012R2v1-2017-07 (shell-local): Post processing with local shell script: C:\Users\ADMINI~1.ISS\AppData\Local\
Temp\packer-shell402030443
Build 'Windows2012R2v1-2017-07' errored: 1 error(s) occurred:

* Post-processor failed: Error executing script: C:\Users\ADMINI~1.ISS\AppData\Local\Temp\packer-shell402030443

Rickard von Essen

unread,
Jul 5, 2017, 1:41:13 AM7/5/17
to packe...@googlegroups.com
run with PACKER_LOG=1 and attache interesting parts of the log.
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/0d4267bb-dd48-4e9f-bc0f-6e784e06cf30%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

James Elmes

unread,
Jul 5, 2017, 7:12:53 PM7/5/17
to Packer
The log doesn't really say anything, see below. I am running this on a windows machine, is there something else i need to do.. like use the "execute-command" option?

2017/07/05 21:12:19 packer.exe: 2017/07/05 21:12:19 starting remote command: ls -1p /vmfs/volumes/datastore1/output-Windows2012R2v1-2017-07
2017/07/05 21:12:19 ui: ==> Windows2012R2v1-2017-07: Running post-processor: shell-local
2017/07/05 21:12:19 ui: ==> Windows2012R2v1-2017-07 (shell-local): Post processing with local shell script: C:\Users\ADMINI~1.ISS\AppData\Local\Temp\packer-shell486898063
2017/07/05 21:12:19 packer.exe: 2017/07/05 21:12:19 starting local command: chmod +x "C:\Users\ADMINI~1.ISS\AppData\Local\Temp\packer-shell486898063"; PACKER_BUILDER_TYPE='vmware-iso' PACKER_BUILD_NAME='Windows2012R2v1-2017-07'  "C:\Users\ADMINI~1.ISS\AppData\Local\Temp\packer-shell486898063"
2017/07/05 21:12:19 Deleting original artifact for build 'Windows2012R2v1-2017-07'
2017/07/05 21:12:19 packer.exe: 2017/07/05 21:12:19 opening new ssh session
2017/07/05 21:12:19 packer.exe: 2017/07/05 21:12:19 starting remote command: rm -rf /vmfs/volumes/datastore1/output-Windows2012R2v1-2017-07
2017/07/05 21:12:19 ui error: Build 'Windows2012R2v1-2017-07' errored: 1 error(s) occurred:

* Post-processor failed: Error executing script: C:\Users\ADMINI~1.ISS\AppData\Local\Temp\packer-shell486898063

Rickard von Essen

unread,
Jul 6, 2017, 1:32:56 AM7/6/17
to packe...@googlegroups.com
Seems like it tries to chmod the script on windows. 
starting local command: chmod +x "C:\Users\ADMINI~1.ISS\AppData\Local\Temp\packer-shell486898063"; 

The problem with shell-local is that it ties the template to a host machine with certain properties (OS, tools, etc). You can try to override some of the configuration options such as execute_command but I'm not sure it will work for Windows. 

--
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/fd0bb126-2f6d-49a9-a2c4-2d7f3d65d2bb%40googlegroups.com.

James Elmes

unread,
Jul 6, 2017, 1:39:57 AM7/6/17
to Packer
so this cannot run on windows? do you know how i can change the post-processor local-shell to run on windows?

regards

James

Rickard von Essen

unread,
Jul 6, 2017, 1:57:18 AM7/6/17
to packe...@googlegroups.com
> so this cannot run on windows? 

At least not without modification.


> do you know how i can change the post-processor local-shell to run on windows?

I'm not sure, I don't have any Windows machine and don't really know much about windows. Just found https://github.com/hashicorp/packer/issues/4140 please track that.

--
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.
Reply all
Reply to author
Forward
0 new messages