Merge pull request #5341 from c22/issue_5338

Fix facterVar separator bug reported in #5338
This commit is contained in:
Matthew Hooker 2017-09-29 09:49:22 -07:00 committed by GitHub
commit d26e28a028
2 changed files with 16 additions and 10 deletions

View File

@ -71,6 +71,7 @@ type guestOSTypeConfig struct {
stagingDir string
executeCommand string
facterVarsFmt string
facterVarsJoiner string
modulePathJoiner string
}
@ -86,6 +87,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{
"{{if ne .ExtraArguments \"\"}}{{.ExtraArguments}} {{end}}" +
"{{.ManifestFile}}",
facterVarsFmt: "FACTER_%s='%s'",
facterVarsJoiner: " ",
modulePathJoiner: ":",
},
provisioner.WindowsOSType: {
@ -98,7 +100,8 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{
"--detailed-exitcodes " +
"{{if ne .ExtraArguments \"\"}}{{.ExtraArguments}} {{end}}" +
"{{.ManifestFile}}",
facterVarsFmt: "SET \"FACTER_%s=%s\" &",
facterVarsFmt: "SET \"FACTER_%s=%s\"",
facterVarsJoiner: " & ",
modulePathJoiner: ";",
},
}
@ -282,7 +285,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
// Execute Puppet
p.config.ctx.Data = &ExecuteTemplate{
FacterVars: strings.Join(facterVars, " "),
FacterVars: strings.Join(facterVars, p.guestOSTypeConfig.facterVarsJoiner),
HieraConfigPath: remoteHieraConfigPath,
ManifestDir: remoteManifestDir,
ManifestFile: remoteManifestFile,

View File

@ -15,9 +15,10 @@ import (
)
type guestOSTypeConfig struct {
executeCommand string
facterVarsFmt string
stagingDir string
executeCommand string
facterVarsFmt string
facterVarsJoiner string
stagingDir string
}
var guestOSTypeConfigs = map[string]guestOSTypeConfig{
@ -31,8 +32,9 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{
"{{if ne .ClientCertPath \"\"}}--certdir='{{.ClientCertPath}}' {{end}}" +
"{{if ne .ClientPrivateKeyPath \"\"}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}" +
"--detailed-exitcodes",
facterVarsFmt: "FACTER_%s='%s'",
stagingDir: "/tmp/packer-puppet-server",
facterVarsFmt: "FACTER_%s='%s'",
facterVarsJoiner: " ",
stagingDir: "/tmp/packer-puppet-server",
},
provisioner.WindowsOSType: {
executeCommand: "{{.FacterVars}} " +
@ -44,8 +46,9 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{
"{{if ne .ClientCertPath \"\"}}--certdir='{{.ClientCertPath}}' {{end}}" +
"{{if ne .ClientPrivateKeyPath \"\"}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}" +
"--detailed-exitcodes",
facterVarsFmt: "SET \"FACTER_%s=%s\" &",
stagingDir: "C:/Windows/Temp/packer-puppet-server",
facterVarsFmt: "SET \"FACTER_%s=%s\"",
facterVarsJoiner: " & ",
stagingDir: "C:/Windows/Temp/packer-puppet-server",
},
}
@ -222,7 +225,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
// Execute Puppet
p.config.ctx.Data = &ExecuteTemplate{
FacterVars: strings.Join(facterVars, " "),
FacterVars: strings.Join(facterVars, p.guestOSTypeConfig.facterVarsJoiner),
ClientCertPath: remoteClientCertPath,
ClientPrivateKeyPath: remoteClientPrivateKeyPath,
PuppetNode: p.config.PuppetNode,