hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.05k stars 3.32k forks source link

Packer template imports and inheritance #5286

Closed labmonkey42 closed 7 years ago

labmonkey42 commented 7 years ago

I have a use case similar to that described by Rajat in #4157. That issue suggests racker as a separate tool for managing template mergers, however I propose that template merging can be done directly within packer.

Looking at template/template.go and template/parse.go, it would appear that rawTemplate could be modified to include "Imports []map[string]interface{}" such that we parse imported JSON depth-first and produce the resulting Template with logical overrides. I am currently prepared to experiment with this feature but before just blindly submitting a PR I thought I would pose this as a feature request and solicit feedback from the team.

If you agree that this feature would indeed be useful, I will begin work on a PR.

mwhooker commented 7 years ago

Thanks for the interest, @labmonkey42, but we're not currently interested in changing templating for now. We have plans to completely rework it in the near future, and don't want to support any changes to it right now. I believe it's certainly possible to do this from within packer, but our position is still that it's best handled outside of the tool.

Thanks!

labmonkey42 commented 7 years ago

@mwhooker Thanks for the feedback. This is exactly why I posted here before working on a PR.

rothgar commented 5 years ago

Is doing this via an outside tool still the recommended approach? I'd like to do the same thing but would prefer to have something natively supported. I didn't see anything that would allow this behavior in hcl2 but maybe I missed it.

SwampDragons commented 5 years ago

Yeah, right now we're still recommending that you do your extra template manipulation outside the tool. I know it would be nice to have it natively supported, but given that there are lots of viable workarounds, I think it makes sense for us to focus our engineering effort on things that users can't achieve through preprocessing.

ghost commented 4 years ago

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.