-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom provisioning hooks #5972
Comments
I looked into the hooks a while ago in order to do something similar, but found it wasn't as flexible as I needed it to be. fwiw my solution was to modify packer/provisioner.go directly 😭 I sympathize with your desire. I think committing between provisions makes a lot of sense, but I can't recommend modifying the hooking mechanism. We can't really support changes to this system, as our efforts now are focused on replacing it. Take a look at builder/docker/communicator_test.go, where we use the Hooks to mock out tests. // Add hooks so the provisioners run during the build
hooks := map[string][]packer.Hook{}
hooks[packer.HookProvision] = []packer.Hook{
&packer.ProvisionHook{
Provisioners: []*packer.HookedProvisioner{
// weave in commit provisioning here.
},
},
}
hook := &packer.DispatchHook{Mapping: hooks} I might be more amenable to something like that. I'm going to close this since this isn't something we plan on working on, but if you wanted to submit a proof of concept PR, we can talk more about it there |
Thanks @mwhooker for getting back to me so soon! I am willing to submit a PoC PR, but I need some help to do that. I am having a bit of a trouble understanding some of the details of how provisioners are actually run today. I went through the documentation, but it doesn't say anything in detail. This is mostly in respect to Is
And third and final question, should I be using I am sorry for a lot of questions, I am quite new to Golang and so struggling a little with common design patterns and navigating through the codebase. And thanks a lot again for your help! |
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. |
Right now,
common.StepProvision.Run()
usespacker.HookProvision
to invoke the different provisioners. However,packer.HookProvision
is hard-coded and there is no way to actually change the provisioning behavior.Why would I need to do something like that?
My current use case is to use
docker
builder to create "layered" images. Since by default, packer commits the container after all the provisioners have run, it creates a single layer. By adding aCommitStep
after every provisioner runs, I think I can have a good way to do layering and separating different contents in layers. Please let me know if you have any other/better way achieve this.So, the way I plan to do this by having a separate implementation of
Hook
interface defined inpacker/hooks.go
and use that incommon.StepProvision.Run()
by allowing a configuration (called as a template in packer world?) to define whatprovision_hook
I want to use. Then, my implmentation ofHook
interface would take care of adding aCommitStep
after each provisioner has run.Do you think that makes any sense?
The text was updated successfully, but these errors were encountered: