Commit eb4ba76e authored by James Cline's avatar James Cline

provisioner/chef-client: validation_client_name

Allows setting of validation_client_name from packer template json.
parent 8dcabe97
...@@ -33,6 +33,7 @@ type Config struct { ...@@ -33,6 +33,7 @@ type Config struct {
SkipInstall bool `mapstructure:"skip_install"` SkipInstall bool `mapstructure:"skip_install"`
StagingDir string `mapstructure:"staging_directory"` StagingDir string `mapstructure:"staging_directory"`
ValidationKeyPath string `mapstructure:"validation_key_path"` ValidationKeyPath string `mapstructure:"validation_key_path"`
ValidationClientName string `mapstructure:"validation_client_name"`
tpl *packer.ConfigTemplate tpl *packer.ConfigTemplate
} }
...@@ -45,6 +46,7 @@ type ConfigTemplate struct { ...@@ -45,6 +46,7 @@ type ConfigTemplate struct {
NodeName string NodeName string
ServerUrl string ServerUrl string
ValidationKeyPath string ValidationKeyPath string
ValidationClientName string
} }
type ExecuteTemplate struct { type ExecuteTemplate struct {
...@@ -188,7 +190,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { ...@@ -188,7 +190,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
} }
configPath, err := p.createConfig( configPath, err := p.createConfig(
ui, comm, nodeName, serverUrl, remoteValidationKeyPath) ui, comm, nodeName, serverUrl, remoteValidationKeyPath, p.config.ValidationClientName)
if err != nil { if err != nil {
return fmt.Errorf("Error creating Chef config file: %s", err) return fmt.Errorf("Error creating Chef config file: %s", err)
} }
...@@ -242,7 +244,7 @@ func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, ds ...@@ -242,7 +244,7 @@ func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, ds
return comm.UploadDir(dst, src, nil) return comm.UploadDir(dst, src, nil)
} }
func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, nodeName string, serverUrl string, remoteKeyPath string) (string, error) { func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, nodeName string, serverUrl string, remoteKeyPath string, validationClientName string) (string, error) {
ui.Message("Creating configuration file 'client.rb'") ui.Message("Creating configuration file 'client.rb'")
// Read the template // Read the template
...@@ -266,6 +268,7 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, nodeN ...@@ -266,6 +268,7 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, nodeN
NodeName: nodeName, NodeName: nodeName,
ServerUrl: serverUrl, ServerUrl: serverUrl,
ValidationKeyPath: remoteKeyPath, ValidationKeyPath: remoteKeyPath,
ValidationClientName: validationClientName,
}) })
if err != nil { if err != nil {
return "", err return "", err
...@@ -481,7 +484,11 @@ var DefaultConfigTemplate = ` ...@@ -481,7 +484,11 @@ var DefaultConfigTemplate = `
log_level :info log_level :info
log_location STDOUT log_location STDOUT
chef_server_url "{{.ServerUrl}}" chef_server_url "{{.ServerUrl}}"
{{if ne .ValidationClientName ""}}
validation_client_name "{{.ValidationClientName}}"
{{else}}
validation_client_name "chef-validator" validation_client_name "chef-validator"
{{end}}
{{if ne .ValidationKeyPath ""}} {{if ne .ValidationKeyPath ""}}
validation_key "{{.ValidationKeyPath}}" validation_key "{{.ValidationKeyPath}}"
{{end}} {{end}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment