Packer doesn't run provisioner or postprocesser, after running a custom Builder plugin.

54 views
Skip to first unread message

CHUA Chee Wee

unread,
May 19, 2018, 11:17:52 AM5/19/18
to Packer
Hi,

I have a custom Builder running, and it's working, if I use the Builders section only.
If I add the provisioners section, the scripts in the provisioners section doesn't run.

Any idea why this is, and how to get the provisioners section to work?
The scripts are meant to be run on Linux.

Initially, my custom Builder doesn't have any Provisioner or PostProcessor built-in.
However, operating under the assumption that perhaps Packer is looking into loading Provisioner and PostProcessor from my plugin, I tried using the Provisioner and PostProcessor code from Packer, by exporting it into my namespace. So plugin.cmdProvisioner became myplugin.Provisioner, and plugin.cmdPostProcessor became myplugin.PostProcessor.

Here's my main routine (which is for my custom Builder) before adding provisioner and postprocessor:
func main() {
    server, err := plugin.Server()
    if err != nil {
        panic(err)
    }
    server.RegisterBuilder(new(myplugin.Builder))
    server.Serve()
}
The above works, and my Builder can build images successfully

Here's my routine (still inside my own Builder) after adding provisioner and postprocessor:
func main() {
    server, err := plugin.Server()
    if err != nil {
        panic(err)
    }
    server.RegisterBuilder(new(myplugin.Builder))
    server.RegisterProvisioner(new(myplugin.Provisioner))
    server.RegisterPostProcessor(new(myplugin.PostProcessor))
    server.Serve()

}

Here's my configuration file:

{
  "min_packer_version": "0.12.0",
  "builders": [{
    ... // omitted as this part is working ///
  }],
  "provisioners": [
    {
    "type": "shell-local",
    "command": "echo Hello World > /home/chuacw/successful.txt"
    }
  ],
  "post-processors": [{
    "type": "manifest",
    "output": "manifests/test-node.json",
    "strip_path": true
  }]
 
}

CHUA Chee Wee

unread,
May 19, 2018, 11:41:28 AM5/19/18
to Packer
Both the host and the VM are on Linux.

So, a simple echo should work.

Rickard von Essen

unread,
May 19, 2018, 2:03:32 PM5/19/18
to packe...@googlegroups.com
For the provisioners to run you need to implement a connect step and a provision step. Example:

Post-processors I think will run as long as you return an artifact. Example:

Is your code available somewhere?

On 19 May 2018 at 17:41, CHUA Chee Wee <chu...@gmail.com> wrote:
Both the host and the VM are on Linux.

So, a simple echo should work.

--
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/13b11871-5d18-481b-b697-9b75905e88f8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

CHUA Chee Wee

unread,
May 20, 2018, 12:28:32 AM5/20/18
to Packer
Thank you, Rickard!

I've just tested your statement, and for provisioners to run, as long as the provisioner is local, all it needs is a provision Step, which is as simple as follows:

steps = append(steps, new(packerCommon.StepProvision))

It doesn't need a connect step. Not unless there's a need to execute provisioning steps remotely on the new build target

My code is currently experimental, so it's not available online yet.

On Sunday, May 20, 2018 at 2:03:32 AM UTC+8, Rickard von Essen wrote:
For the provisioners to run you need to implement a connect step and a provision step. Example:

Post-processors I think will run as long as you return an artifact. Example:

Is your code available somewhere?
On 19 May 2018 at 17:41, CHUA Chee Wee <chu...@gmail.com> wrote:
Both the host and the VM are on Linux.

So, a simple echo should work.

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