Create inventory file ./hosts
as below.
[some-servers]
10.1.1.1 # IP address or hostname
Setting ssh configuration as below.
$ vagrant ssh-config > ssh.config
Edit ssh.config
as below.
- Host HOSTNAME_OF_YOUR_VM
+ Host IP_ADDRESSS
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/momota/dev/ocr/mysql/.vagrant/machines/db01/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
Create ansible configure file ./ansible.cfg
.
[defaluts]
hostfile = hosts
[ssh_connection]
ssh_args = -F ssh.config
Try access to the vagrant host by using ansible.
$ ansible all -m ping
# You don't need type all options
# =>$ ansible -i hosts all -m ping -u vagrant --private-key=.vagrant/machines/YOUR_HOST/virtualbox/private_key