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.
1) https://www.packer.io/docs/builders/amazon-ebs.html#source_ami_filter On 28 December 2017 at 13:06, Alvaro Miranda Aguilera <[email protected]> wrote: > 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. > > On Thu, Dec 28, 2017 at 4:40 AM, James McCallum <[email protected]> > wrote: > >> 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? >> >> POC source code: https://github.com/jamesla/packer-test-plugin/tree/ >> call_openstack_plugin >> >> -- >> 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 [email protected]. >> To view this discussion on the web visit https://groups.google.com/d/ms >> gid/packer-tool/c5cb3d59-2d4f-4421-8217-2497bde268c7%40googlegroups.com >> <https://groups.google.com/d/msgid/packer-tool/c5cb3d59-2d4f-4421-8217-2497bde268c7%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > 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 [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/packer-tool/CAHqq0exz_hXTL%2BG-vV9MnmGVyMXJ7U- > uoMYGOf0-p6%3DOi84fOg%40mail.gmail.com > <https://groups.google.com/d/msgid/packer-tool/CAHqq0exz_hXTL%2BG-vV9MnmGVyMXJ7U-uoMYGOf0-p6%3DOi84fOg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt-r%2BzhcWt_uK8zXodCt%3DoUbsz_d3Qd4bOR3eDBgKQ9UPw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
