packer-plugin-ansible icon indicating copy to clipboard operation
packer-plugin-ansible copied to clipboard

`host_alias` does not exist for ansible-local

Open michaeltinsley opened this issue 3 years ago • 0 comments

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

The documentation (here) show the host_alias, however in practice the HCL file isn't valid. I think either the documentation is incorrect or the code is as host_alias var doesn't seem to exist for ansible-local (however golang is pretty unknown to me). I imagine it is supposed to exist, although a workaround is to add an inventory_group.

Reproduction Steps

Steps to reproduce this issue

Plugin and Packer version

From packer version

Packer = 1.7.3 Ansible plugin = 1.0.0

Simplified Packer Buildfile


packer {
  required_plugins {
    vagrant = {
      version = ">= 1.0.0"
      source = "github.com/hashicorp/vagrant"
    }
  }
  required_plugins {
    ansible = {
      version = ">= 1.0.0"
      source = "github.com/hashicorp/ansible"
    }
  }
}

source "vagrant" "my-box" {
  communicator = "ssh"
  source_path = "geerlingguy/centos8"
  provider = "virtualbox"
  output_dir = "build"
}


build {
  sources = [
    "source.vagrant.my-box"]


  provisioner "shell" {
    inline = [
      "sudo yum install epel-release -y",
      "sudo yum install ansible -y",
    ]
  }

  provisioner "ansible-local" {
    host_alias    = "my-box"
    playbook_file = "./playbook.yml"
    galaxy_file = "./requirements.yml"
  }
}

Operating system and Environment details

OS, Architecture, and any other information you can provide about the environment.

  • Windows 10
  • x86

Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Set the env var PACKER_LOG=1 for maximum log detail.

michaeltinsley avatar Jun 23 '21 14:06 michaeltinsley