added support for specifying an execute command to the puppet-server provisioner.

This commit is contained in:
Tom Asquith 2016-06-13 14:12:28 +01:00
parent 73d376633d
commit 40aa2b9973
2 changed files with 27 additions and 3 deletions

View File

@ -17,6 +17,9 @@ 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
}

View File

@ -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
```