Merge pull request #3614 from tasquith/master
added support for specifying an execute command to the puppet-server provisioner
This commit is contained in:
commit
1acb2d6645
|
@ -17,6 +17,9 @@ type Config struct {
|
||||||
common.PackerConfig `mapstructure:",squash"`
|
common.PackerConfig `mapstructure:",squash"`
|
||||||
ctx interpolate.Context
|
ctx interpolate.Context
|
||||||
|
|
||||||
|
// The command used to execute Puppet.
|
||||||
|
ExecuteCommand string `mapstructure:"execute_command"`
|
||||||
|
|
||||||
// Additional facts to set when executing Puppet
|
// Additional facts to set when executing Puppet
|
||||||
Facter map[string]string
|
Facter map[string]string
|
||||||
|
|
||||||
|
@ -65,13 +68,19 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||||
Interpolate: true,
|
Interpolate: true,
|
||||||
InterpolateContext: &p.config.ctx,
|
InterpolateContext: &p.config.ctx,
|
||||||
InterpolateFilter: &interpolate.RenderFilter{
|
InterpolateFilter: &interpolate.RenderFilter{
|
||||||
Exclude: []string{},
|
Exclude: []string{
|
||||||
|
"execute_command",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}, raws...)
|
}, raws...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.config.ExecuteCommand == "" {
|
||||||
|
p.config.ExecuteCommand = p.commandTemplate()
|
||||||
|
}
|
||||||
|
|
||||||
if p.config.StagingDir == "" {
|
if p.config.StagingDir == "" {
|
||||||
p.config.StagingDir = "/tmp/packer-puppet-server"
|
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,
|
Options: p.config.Options,
|
||||||
Sudo: !p.config.PreventSudo,
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,3 +74,18 @@ listed below:
|
||||||
must have proper permissions so that the SSH user that Packer uses is able
|
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
|
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.
|
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
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue