Merge pull request #1343 from fnoeding/templating
Added support to use templates for more fields in null-builder and amazon-builder
This commit is contained in:
commit
7439baf75e
|
@ -98,6 +98,8 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
|
|||
"temporary_key_pair_name": &c.TemporaryKeyPairName,
|
||||
"vpc_id": &c.VpcId,
|
||||
"availability_zone": &c.AvailabilityZone,
|
||||
"user_data": &c.UserData,
|
||||
"user_data_file": &c.UserDataFile,
|
||||
}
|
||||
|
||||
for n, ptr := range templates {
|
||||
|
|
|
@ -32,14 +32,28 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
|
||||
c.tpl.UserVars = c.PackerUserVars
|
||||
|
||||
// Defaults
|
||||
if c.Port == 0 {
|
||||
c.Port = 22
|
||||
}
|
||||
// (none so far)
|
||||
|
||||
errs := common.CheckUnusedConfig(md)
|
||||
|
||||
templates := map[string]*string{
|
||||
"host": &c.Host,
|
||||
"ssh_username": &c.SSHUsername,
|
||||
"ssh_password": &c.SSHPassword,
|
||||
"ssh_private_key_file": &c.SSHPrivateKeyFile,
|
||||
}
|
||||
|
||||
for n, ptr := range templates {
|
||||
var err error
|
||||
*ptr, err = c.tpl.Process(*ptr, nil)
|
||||
if err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("Error processing %s: %s", n, err))
|
||||
}
|
||||
}
|
||||
|
||||
if c.Host == "" {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("host must be specified"))
|
||||
|
|
Loading…
Reference in New Issue