added parameter for setting packer password as env variable
This commit is contained in:
parent
1b967e60f9
commit
37fd50995f
|
@ -57,6 +57,7 @@ type Config struct {
|
||||||
UseSFTP bool `mapstructure:"use_sftp"`
|
UseSFTP bool `mapstructure:"use_sftp"`
|
||||||
InventoryDirectory string `mapstructure:"inventory_directory"`
|
InventoryDirectory string `mapstructure:"inventory_directory"`
|
||||||
InventoryFile string `mapstructure:"inventory_file"`
|
InventoryFile string `mapstructure:"inventory_file"`
|
||||||
|
SetPackerPasswd bool `mapstructure:"set_packer_passwd"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Provisioner struct {
|
type Provisioner struct {
|
||||||
|
@ -118,6 +119,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||||
p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "ANSIBLE_SCP_IF_SSH=True")
|
p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "ANSIBLE_SCP_IF_SSH=True")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.config.SetPackerPasswd {
|
||||||
|
p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "PACKER_RANDOM_PASSWORD=TEST")
|
||||||
|
}
|
||||||
|
|
||||||
if len(p.config.LocalPort) > 0 {
|
if len(p.config.LocalPort) > 0 {
|
||||||
if _, err := strconv.ParseUint(p.config.LocalPort, 10, 16); err != nil {
|
if _, err := strconv.ParseUint(p.config.LocalPort, 10, 16); err != nil {
|
||||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("local_port: %s must be a valid port", p.config.LocalPort))
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("local_port: %s must be a valid port", p.config.LocalPort))
|
||||||
|
|
Loading…
Reference in New Issue