Packer and Asnible Vars file

I’m wondering how I can pass a ansible variables file to the Ansible provisioner? I’m trying to avoid having to define 80 variables in the extra-args part of the provider. Does anyone have an example? we have about 10 roles and they all are generating configuration file and first run script that goes and pulls down ssl certs from the vault on start up.

If you are using a var files, you can reference it with @<path to vars file>. For example

provisioner "ansible" {
  playbook_file = "playbook.yaml"
  extra_arguments = [
    "--extra_vars", "@vars.yaml"
  ]
}

vars from a JSON or YAML file took a little bit of searching for me to find this when I had the same problem you are.