Merge branch 'additional-user-variables' of github.com:nBerg/packer into nBerg-additional-user-variables

Conflicts:
	builder/amazon/common/run_config.go
This commit is contained in:
Mitchell Hashimoto 2014-09-02 09:57:52 -07:00
commit 825864a9ea
2 changed files with 49 additions and 20 deletions

View File

@ -42,6 +42,32 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
}
}
templates := map[string]*string{
"iam_instance_profile": &c.IamInstanceProfile,
"instance_type": &c.InstanceType,
"ssh_timeout": &c.RawSSHTimeout,
"ssh_username": &c.SSHUsername,
"ssh_private_key_file": &c.SSHPrivateKeyFile,
"source_ami": &c.SourceAmi,
"subnet_id": &c.SubnetId,
"temporary_key_pair_name": &c.TemporaryKeyPairName,
"vpc_id": &c.VpcId,
"availability_zone": &c.AvailabilityZone,
"user_data": &c.UserData,
"user_data_file": &c.UserDataFile,
"security_group_id": &c.SecurityGroupId,
}
errs := make([]error, 0)
for n, ptr := range templates {
var err error
*ptr, err = t.Process(*ptr, nil)
if err != nil {
errs = append(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
// Defaults
if c.SSHPort == 0 {
c.SSHPort = 22
@ -57,7 +83,6 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
// Validation
var err error
errs := make([]error, 0)
if c.SourceAmi == "" {
errs = append(errs, errors.New("A source_ami must be specified"))
}

View File

@ -71,6 +71,29 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
}
p.config.tpl.UserVars = p.config.PackerUserVars
// Accumulate any errors
errs := common.CheckUnusedConfig(md)
templates := map[string]*string{
"config_template": &p.config.ConfigTemplate,
"node_name": &p.config.NodeName,
"staging_dir": &p.config.StagingDir,
"chef_server_url": &p.config.ServerUrl,
"execute_command": &p.config.ExecuteCommand,
"install_command": &p.config.InstallCommand,
"validation_key_path": &p.config.ValidationKeyPath,
"validation_client_name": &p.config.ValidationClientName,
}
for n, ptr := range templates {
var err error
*ptr, err = p.config.tpl.Process(*ptr, nil)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
if p.config.ExecuteCommand == "" {
p.config.ExecuteCommand = "{{if .Sudo}}sudo {{end}}chef-client " +
"--no-color -c {{.ConfigPath}} -j {{.JsonPath}}"
@ -90,25 +113,6 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
p.config.StagingDir = "/tmp/packer-chef-client"
}
// Accumulate any errors
errs := common.CheckUnusedConfig(md)
templates := map[string]*string{
"config_template": &p.config.ConfigTemplate,
"node_name": &p.config.NodeName,
"staging_dir": &p.config.StagingDir,
"chef_server_url": &p.config.ServerUrl,
}
for n, ptr := range templates {
var err error
*ptr, err = p.config.tpl.Process(*ptr, nil)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
sliceTemplates := map[string][]string{
"run_list": p.config.RunList,
}