How to get Vagrant to reset the SSH keys?
Solution 1:
I did the following, and it worked for me.
Inventory File
#application servers
[app]
192.168.60.4 app1
192.168.60.5 app2
# Database server
[db]
192.168.60.6 db
# Group 'multi' with all servers
[multi:children]
app
db
# Variables that will be applied to all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
My Vagrant file looks like the following:
VAGRANTFILE_API_VERSION="2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM coniguration
config.vm.box="geerlingguy/centos7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant",disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 256
v.linked_clone = true
end
#Application server 1.
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1-test"
app.vm.network :private_network, ip: "192.168.60.4"
end
#Application server 2.
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2-test"
app.vm.network :private_network, ip: "192.168.60.5"
end
#Database server 1.
config.vm.define "db" do |app|
app.vm.hostname = "orc-db-test"
app.vm.network :private_network, ip: "192.168.60.6"
end
#ansible playbook provisioner
# config.vm.provision"ansible"do|ansible|
# ansible.playbook = "playbook.yml"
# end
end
Also, make sure your KnownHost
file is clean.
vi /Users/JohnDoe/.ssh/known_hosts
Basically that's how I'm using my Vagrant with SSH/Ansible