Packer with ansible provisioner

i am using packer for the automated image creation on openstack. i am using ansible for provisioning. my packer machine is different from my ansible machine and in this case how can i use the provisioner:

“provisioners”: [
“type”: “ansible”,
“playbook_file”: “./playbook.yml”, “extra_arguments”: “-vvvv” } ],

playbook.yml is in the different machine. how can i redirect packer to my ansible machine ip address and the location of the yaml file.

is that mandatory to have packer and ansible installed on the same system to have this configuration running

playbook_file (string) - The playbook file to be executed by ansible. This file must exist on your local system and will be uploaded to the remote machine. This option is exclusive with playbook_files .

There is mentioned local system. Why don’t you just rsync or scp the file before? Or you could configure a nfs share to simulate the file from the ansible as a local file on the packer node. Or run packer on the ansible node. It’s just a binary without dependencies so it should be easy to implement.

Whereby a git - or similar vcs - would be very chic as a source. Feature request?

actually i have a dedicated ansible machine which is running on different infra (vmware) which i would like to use it for my packer machine which is in different infra so i thought if it would be possible to provide the path to the yaml file from the remote location.

Hi @allaboutsunil,

Packer does not support executing a provisioner from a remote machine.

The Ansible Provisioner requires that your playbooks are accessible from the machine running Packer. The Ansible Local provisioner allows Packer to execute ansible on the builder using playbooks which are present on the build host.

Hopefully this info helps you in determining the appropriate host on which to execute packer, and the appropriate provisioner to use based on your operational constraints.

thanks for clarifying . it did helped