Ansible playbook with packer in Jenkins
by Emile `iMil' Heitor - 2017-03-25
Quick one.
While working on a build chain in order to register home-baked AMIs, I wanted to use the ansible-local
packer provisioner to setup the instance with a very basic playbook. I needed to provide ansible
a playbook but didn’t find immediately how to achieve this within the Jenkins-packer module. Turns out it’s tricky, in the JSON Template Text (or the template file), declare the playbook_file
like this:
[{
"type": "ansible-local",
"playbook_file": "{{ user `test_yml` }}",
"command": "PYTHONUNBUFFERED=1 ansible-playbook"
}]
Then in the File Entries field, the Variable Name must be test_yml
and File Contents filled with the playbook.