# Run ansible playbook on vagrant machines

**URL:** <https://forum.ansible.com/t/run-ansible-playbook-on-vagrant-machines/27636>\
**Category:** Ansible Project\
**Created:** [May 26, 2018, 2:51am UTC](https://forum.ansible.com/t/run-ansible-playbook-on-vagrant-machines/27636 "2018-05-26T02:51:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravikumar\_Wagh](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Ravikumar\_Wagh](https://forum.ansible.com/u/Ravikumar_Wagh)\
**Post date:** [May 26, 2018, 2:51am UTC](https://forum.ansible.com/t/run-ansible-playbook-on-vagrant-machines/27636/1 "2018-05-26T02:51:54Z")

</div>

Hello,

I wish to run a ansible playbook on vagrant machines. I know vagrant provisioning, but scenario how I wish to run is as below:

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [May 26, 2018, 6:41am UTC](https://forum.ansible.com/t/run-ansible-playbook-on-vagrant-machines/27636/2 "2018-05-26T06:41:14Z")

</div>

ansible\_ssh\_port

[https://docs.ansible.com/ansible/2.5/scenario\_guides/guide\_vagrant.html#running-ansible-manually](https://docs.ansible.com/ansible/2.5/scenario_guides/guide_vagrant.html#running-ansible-manually)

---

<div class="post-metadata">

**Author:** ![js.a](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@js.a](https://forum.ansible.com/u/js.a)\
**Post date:** [June 7, 2018, 3:06am UTC](https://forum.ansible.com/t/run-ansible-playbook-on-vagrant-machines/27636/3 "2018-06-07T03:06:15Z")

</div>

Hello Ravikumar.

I don’t need to be concerned about which ssh port Vagrant is actually using to connect to VMs. Just set up correctly an Ansible’s inventory file passing the credentials for the connection, VM’s IP and names. I have the same scenario you described and everything that I’ve done was:

# inventory file

IPs and names..

…

Groups  
…

# Setting up management connections to hosts

[all:vars]  
ansible\_ssh\_user=vagrant  
ansible\_ssh\_private\_key\_file=/root/.vagrant.d/insecure\_private\_key  
ansible\_ssh\_common\_args=‘-o StrictHostKeyChecking=no’

[user@testenv ~] sudo ansible-playbook -i inventory\_file \_your\_playbook\_file

Of course, it’s a default configuration for testing and controlled environments.

Good luck.  
j.
