Fixing 5852

This commit is contained in:
Marc Mercer 2018-02-07 19:41:01 -08:00
parent 51dcf9ffb1
commit 5d67f77f43
No known key found for this signature in database
GPG Key ID: 95F997BD9E22C058
1 changed files with 5 additions and 1 deletions

View File

@ -327,7 +327,11 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri
p.config.PackerBuildName, p.config.PackerBuilderType),
"-i", inventory, playbook}
if len(privKeyFile) > 0 {
args = append(args, "--private-key", privKeyFile)
// Changed this from using --private-key to supplying -e ansible_ssh_private_key as the latter
// is treated as a highest priority variable, and thus prevents overriding by dynamic variables
// as seen in #5852
// args = append(args, "--private-key", privKeyFile)
args = append(args, "-e", fmt.Sprintf("ansible_ssh_private_key_file=%s", privKeyFile))
}
args = append(args, p.config.ExtraArguments...)
if len(p.config.AnsibleEnvVars) > 0 {