# ansible as a provisioner with packer and docker

**URL:** <https://forum.ansible.com/t/ansible-as-a-provisioner-with-packer-and-docker/31588>\
**Category:** Ansible Project\
**Created:** [November 2, 2019, 6:19pm UTC](https://forum.ansible.com/t/ansible-as-a-provisioner-with-packer-and-docker/31588 "2019-11-02T18:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![darth\_republic](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@darth\_republic](https://forum.ansible.com/u/darth_republic)\
**Post date:** [November 2, 2019, 6:19pm UTC](https://forum.ansible.com/t/ansible-as-a-provisioner-with-packer-and-docker/31588/1 "2019-11-02T18:19:43Z")

</div>

Hi is anyone working with ansible provisioner and playbook ??

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [November 2, 2019, 6:40pm UTC](https://forum.ansible.com/t/ansible-as-a-provisioner-with-packer-and-docker/31588/2 "2019-11-02T18:40:26Z")

</div>

We use the ansible provision with packer. It works something like this:

"provisioners": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"execute\_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh  
'{{ .Path }}'",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"inline": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"sudo yum -y install ansible"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"inline\_shebang": "/bin/sh -x",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "shell"  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "ansible-local",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"playbook\_file": "./ansible/playbook.yml",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"playbook\_dir": "./ansible"  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;]

---

<div class="post-metadata">

**Author:** ![sdoran](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sdoran](https://forum.ansible.com/u/sdoran)\
**Post date:** [November 4, 2019, 3:20pm UTC](https://forum.ansible.com/t/ansible-as-a-provisioner-with-packer-and-docker/31588/3 "2019-11-04T15:20:33Z")

</div>

Yes, I use the Ansible provisioner to build Vagrant boxes with Packer usinge Virtualbox. Here is [one example](https://github.com/samdoran/packer-centos7/blob/master/centos7.json). I imagine it would work against Docker as that is just another Builder to Packer, but I haven’t used it in that way specifically.
