Skip to content
Latchkey

Packer ansible provisioner "ansible-playbook not found" in CI

The Packer ansible provisioner runs ansible-playbook from the runner against the build instance. If Ansible is not installed on the CI runner, the provisioner cannot start.

What this error means

packer build fails with "exec: ansible-playbook: executable file not found in $PATH" when the ansible provisioner tries to run.

packer
Error: exec: "ansible-playbook": executable file not found in $PATH

Build 'amazon-ebs.ubuntu' errored: exec: "ansible-playbook": executable file not
found in $PATH

Common causes

Ansible is not installed on the runner

The ansible provisioner runs on the CI host, not the target. A runner without Ansible cannot invoke ansible-playbook.

ansible-playbook is not on PATH

Ansible is installed under a venv or path the step does not see, so the executable is not found.

How to fix it

Install Ansible before packer build

  1. Add a step that installs Ansible on the runner.
  2. Confirm ansible-playbook --version works.
  3. Run packer build after Ansible is available.
.github/workflows/build.yml
- run: python -m pip install ansible
- run: ansible-playbook --version
- run: packer build .

Point the provisioner at the right binary

If Ansible lives in a venv, set the command path so the provisioner finds it.

build.pkr.hcl
provisioner "ansible" {
  playbook_file = "./playbook.yml"
  command       = ".venv/bin/ansible-playbook"
}

How to prevent it

  • Install Ansible as an explicit CI step before build.
  • Verify ansible-playbook --version in the pipeline.
  • Set the provisioner command when using a venv.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →