I have 4 VMs in my Vagrantfile - 3 application servers and an Ansible control host.
I only use Vagrant to create the VMs as I provision them manually from the ansible control host because I am still creating/editing the ansible scripts.
I can do vagrant ssh ansible
and vagrant ssh app1/2/3
etc. but when I try to do ansible-playbook oracle.yml
from the Ansible control host, SSH fails with
fatal: [192.168.60.10]: UNREACHABLE! => {"changed": false, "msg": "SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}
I can successfully ssh from the Ansible VM to the Oracle VM using user vagrant and password vagrant.
The key parts of my Vagrantfile are:
config.ssh.insert_key = falseconfig.vm.define "db" do |db| db.vm.box = "boxcutter/ol67" db.vm.hostname = "oracle-vm" db.vm.network "forwarded_port", guest: 22, host: 2201, id: "ssh", auto_correct: false db.vm.network "forwarded_port", guest: 1521, host: 1521 db.vm.network "private_network", ip: "192.168.60.10" db.vm.provider "virtualbox" do |v| v.name = "oracle-vm" v.linked_clone = true v.memory = 2048 v.cpus = 2 endend#Optional ansible control machine for Windows usersconfig.vm.define "ansible", autostart: false do |ansible| ansible.vm.box = "williamyeh/ansible" ansible.vm.hostname = "ansible-vm" ansible.vm.network "forwarded_port", guest: 22, host: 2204, id: "ssh", auto_correct: false ansible.vm.network "private_network", ip: "192.168.60.50" ansible.vm.provider "virtualbox" do |v| v.linked_clone = true end #Mount the project directory on the guest so we can run the playbooks from there ansible.vm.synced_folder ".", "/data/ansible", create: trueend
What do I need to put in the Vagrantfile to allow the Ansible VM to connect to the other VMs without requiring a password or extra manual steps after vagrant up
?
This is just for development testing on a private network on developers PCs so security is not really an issue and comes second to ease of implementation and smooth user experience.