diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index 9f1c8bead..d0f49aa19 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -16,6 +16,9 @@ import ( type Config struct { common.PackerConfig `mapstructure:",squash"` ctx interpolate.Context + + // The command used to execute Puppet. + ExecuteCommand string `mapstructure:"execute_command"` // Additional facts to set when executing Puppet Facter map[string]string @@ -65,13 +68,19 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, + Exclude: []string{ + "execute_command", + }, }, }, raws...) if err != nil { return err } - + + if p.config.ExecuteCommand == "" { + p.config.ExecuteCommand = p.commandTemplate() + } + if p.config.StagingDir == "" { p.config.StagingDir = "/tmp/packer-puppet-server" } @@ -153,7 +162,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { Options: p.config.Options, Sudo: !p.config.PreventSudo, } - command, err := interpolate.Render(p.commandTemplate(), &p.config.ctx) + command, err := interpolate.Render(p.config.ExecuteCommand, &p.config.ctx) if err != nil { return err } diff --git a/website/source/docs/provisioners/puppet-server.html.md b/website/source/docs/provisioners/puppet-server.html.md index bf469956b..25593923f 100644 --- a/website/source/docs/provisioners/puppet-server.html.md +++ b/website/source/docs/provisioners/puppet-server.html.md @@ -74,3 +74,18 @@ listed below: must have proper permissions so that the SSH user that Packer uses is able to create directories and write into this folder. If the permissions are not correct, use a shell provisioner prior to this to configure it properly. + +- `execute_command` (string) - This is optional. The command used to execute Puppet. This has + various [configuration template + variables](/docs/templates/configuration-templates.html) available. See + below for more information. By default, Packer uses the following command: + + ``` {{.FacterVars}} {{if .Sudo}} sudo -E {{end}}" + + "puppet agent --onetime --no-daemonize " + + "{{if ne .PuppetServer \"\"}}--server='{{.PuppetServer}}' {{end}}" + + "{{if ne .Options \"\"}}{{.Options}} {{end}}" + + "{{if ne .PuppetNode \"\"}}--certname={{.PuppetNode}} {{end}}" + + "{{if ne .ClientCertPath \"\"}}--certdir='{{.ClientCertPath}}' {{end}}" + + "{{if ne .ClientPrivateKeyPath \"\"}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}" + + "--detailed-exitcodes +```