Use sudo by default, as in puppet-masterless
This commit is contained in:
parent
58b06526f5
commit
9d01684c1c
|
@ -32,6 +32,9 @@ type Config struct {
|
|||
// Additional options to be passed to `puppet agent`.
|
||||
Options string `mapstructure:"options"`
|
||||
|
||||
// If true, `sudo` will NOT be used to execute Puppet.
|
||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||
|
||||
// The directory where files will be uploaded. Packer requires write
|
||||
// permissions in this directory.
|
||||
StagingDir string `mapstructure:"staging_dir"`
|
||||
|
@ -48,6 +51,7 @@ type ExecuteTemplate struct {
|
|||
PuppetNode string
|
||||
PuppetServer string
|
||||
Options string
|
||||
Sudo bool
|
||||
}
|
||||
|
||||
func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||
|
@ -182,6 +186,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
PuppetNode: p.config.PuppetNode,
|
||||
PuppetServer: p.config.PuppetServer,
|
||||
Options: p.config.Options,
|
||||
Sudo: !p.config.PreventSudo,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -240,7 +245,7 @@ func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, ds
|
|||
}
|
||||
|
||||
func (p *Provisioner) commandTemplate() string {
|
||||
return "{{.FacterVars}} " +
|
||||
return "{{.FacterVars}} {{if .Sudo}} sudo -E {{end}}" +
|
||||
"puppet agent --onetime --no-daemonize " +
|
||||
"{{if ne .PuppetServer \"\"}}--server='{{.PuppetServer}}' {{end}}" +
|
||||
"{{if ne .Options \"\"}}{{.Options}} {{end}}" +
|
||||
|
|
|
@ -60,6 +60,10 @@ required. They are listed below:
|
|||
* `puppet_server` (string) - Hostname of the Puppet server. By default
|
||||
"puppet" will be used.
|
||||
|
||||
* `prevent_sudo` (boolean) - By default, the configured commands that are
|
||||
executed to run Puppet are executed with `sudo`. If this is true,
|
||||
then the sudo will be omitted.
|
||||
|
||||
* `staging_directory` (string) - This is the directory where all the configuration
|
||||
of Puppet by Packer will be placed. By default this is "/tmp/packer-puppet-server".
|
||||
This directory doesn't need to exist but must have proper permissions so that
|
||||
|
|
Loading…
Reference in New Issue