override ansible executor inventory to use InventoryDirectory instead of InventoryFile when set

This commit is contained in:
Joshua C. Randall 2018-03-26 17:24:58 +01:00
parent b5635ac393
commit 406bf9c4aa
1 changed files with 3 additions and 0 deletions

View File

@ -321,6 +321,9 @@ func (p *Provisioner) Cancel() {
func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, privKeyFile string) error {
playbook, _ := filepath.Abs(p.config.PlaybookFile)
inventory := p.config.inventoryFile
if len(p.config.InventoryDirectory) > 0 {
inventory = p.config.InventoryDirectory
}
var envvars []string
args := []string{"--extra-vars", fmt.Sprintf("packer_build_name=%s packer_builder_type=%s",