How to call a builder from within another plugin in Packer?

23 views
Skip to first unread message

James McCallum

unread,
Dec 27, 2017, 10:40:43 PM12/27/17
to Packer
I am trying to create a custom packer plugin that can resolve the latest version of an image in openstack and then call the Openstack builder using that as the source image. I am also learning golang while I do this.

My plan is to create a custom builder which will handle the lookup and then call the existing Openstack Builder using the resolved image name and pass the other parameters through.

So far I have created the plugin and it's building and trying to call the openstack.Builder functionality, however the plugin just hangs.

james output will be in this color.

2017/12/28 14:39:45 james: 2017/12/28 14:39:45 Serving a plugin connection...
2017/12/28 14:39:45 ui: james output will be in this color.
2017/12/28 14:39:45 ui:
2017/12/28 14:39:45 Build debug mode: false
2017/12/28 14:39:45 Force build: false
2017/12/28 14:39:45 On error:
2017/12/28 14:39:45 Preparing build: james
2017/12/28 14:39:45 Waiting on builds to complete...
2017/12/28 14:39:45 Starting build run: james
2017/12/28 14:39:45 Running builder: james
2017/12/28 14:39:45 [INFO] (telemetry) Starting builder james
2017/12/28 14:39:45 ui: ==> james: in say
==> james: in say
2017/12/28 14:39:45 james: 2017/12/28 14:39:45 Plugin minimum port: 10000
2017/12/28 14:39:45 james: 2017/12/28 14:39:45 Plugin maximum port: 25000
2017/12/28 14:39:45 james: 2017/12/28 14:39:45 Plugin address: unix /tmp/packer-plugin904167325
2017/12/28 14:39:45 james: 2017/12/28 14:39:45 Waiting for connection...
(hangs here)

Does anybody know how I can call a builder from within another builder?

Alvaro Miranda Aguilera

unread,
Dec 28, 2017, 7:06:57 AM12/28/17
to packe...@googlegroups.com
Hello

My understanding is there is no way to do this, since even the local-shell that run before the builder can't be used to create metadata to the current build.

You will be better to have an small tool or script hat create an small var file in json format and then just call packer build -var-file <file> <template>

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/c5cb3d59-2d4f-4421-8217-2497bde268c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Rickard von Essen

unread,
Dec 28, 2017, 9:37:15 AM12/28/17
to packe...@googlegroups.com
I think as Alvaro said the simplest solution is to build a small wrapper script and pass the source_image in as a variable. Another better alternative is to implement something similar to amazon's source_ami_filter 1) and open a PR to include this in the openstack builder.


Reply all
Reply to author
Forward
0 new messages