Run ansible playbook on vagrant machines

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:

ansible_ssh_port

https://docs.ansible.com/ansible/2.5/scenario_guides/guide_vagrant.html#running-ansible-manually

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.