hashicorp / hashicorp/packer-plugin-ansible

`host_alias` does not exist for ansible-local

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
64
Forks
40
PR merge metrics
No merged PRs in 30d

Description

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)](https://www.packer.io/docs/provisioners/ansible/ansible-local#host_alias) 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

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](https://gist.github.com/) of the log or
use the [Github detailed format](https://gist.github.com/ericclemmons/b146fe5da72ca1f706b2ef72a20ac39d) instead of posting it directly in the issue.

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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the HCL validation failure in the ansible-local provisioner using the configuration shown, then compare its accepted options with the linked host_alias documentation. Done means either host_alias works for ansible-local with coverage for the behavior, or the documentation accurately describes the supported configuration and workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible, go
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.