provisioner/puppet-masterless: use Go 1.2 template comparators

This commit is contained in:
Mitchell Hashimoto 2013-12-11 12:37:54 -08:00
parent ae00414bbf
commit 895d87d9eb
2 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,12 @@
## 0.5.0 (unreleased) ## 0.5.0 (unreleased)
BACKWARDS INCOMPATIBILITIES:
* provisioner/puppet-masterless: The `execute_command` no longer has
the `Has*` variables, since the templating language now supports
comparison operations. See the Go documentation for more info:
http://golang.org/pkg/text/template/
IMPROVEMENTS: IMPROVEMENTS:
* core: Plugins communicate over a single TCP connection per plugin now, * core: Plugins communicate over a single TCP connection per plugin now,

View File

@ -49,11 +49,9 @@ type Provisioner struct {
type ExecuteTemplate struct { type ExecuteTemplate struct {
FacterVars string FacterVars string
HasHieraConfigPath bool
HieraConfigPath string HieraConfigPath string
ModulePath string ModulePath string
ManifestFile string ManifestFile string
HasManifestDir bool
ManifestDir string ManifestDir string
Sudo bool Sudo bool
} }
@ -77,8 +75,8 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
if p.config.ExecuteCommand == "" { if p.config.ExecuteCommand == "" {
p.config.ExecuteCommand = "{{.FacterVars}} {{if .Sudo}} sudo -E {{end}}" + p.config.ExecuteCommand = "{{.FacterVars}} {{if .Sudo}} sudo -E {{end}}" +
"puppet apply --verbose --modulepath='{{.ModulePath}}' " + "puppet apply --verbose --modulepath='{{.ModulePath}}' " +
"{{if .HasHieraConfigPath}}--hiera_config='{{.HieraConfigPath}}' {{end}}" + "{{if .HieraConfigPath ne ""}}--hiera_config='{{.HieraConfigPath}}' {{end}}" +
"{{if .HasManifestDir}}--manifestdir='{{.ManifestDir}}' {{end}}" + "{{if .ManifestDir ne ""}}--manifestdir='{{.ManifestDir}}' {{end}}" +
"--detailed-exitcodes " + "--detailed-exitcodes " +
"{{.ManifestFile}}" "{{.ManifestFile}}"
} }
@ -262,9 +260,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
// Execute Puppet // Execute Puppet
command, err := p.config.tpl.Process(p.config.ExecuteCommand, &ExecuteTemplate{ command, err := p.config.tpl.Process(p.config.ExecuteCommand, &ExecuteTemplate{
FacterVars: strings.Join(facterVars, " "), FacterVars: strings.Join(facterVars, " "),
HasHieraConfigPath: remoteHieraConfigPath != "",
HieraConfigPath: remoteHieraConfigPath, HieraConfigPath: remoteHieraConfigPath,
HasManifestDir: remoteManifestDir != "",
ManifestDir: remoteManifestDir, ManifestDir: remoteManifestDir,
ManifestFile: remoteManifestFile, ManifestFile: remoteManifestFile,
ModulePath: strings.Join(modulePaths, ":"), ModulePath: strings.Join(modulePaths, ":"),