I am currently trying to get into ansible and for that usecase i have setup a cluster of 3 VMs using VirtualBox and Vagrant. Now my VM-Setup looks like this
Vagrantfile
$inline_m1 = <<SCRIPT
yum -y update
yum install -y git
yum install -y ansible
SCRIPT
$inline_n1_n2 = <<SCRIPT
yum -y update
yum install -y git
SCRIPT
Vagrant.configure(2) do |config|
config.vm.define "master1" do |conf|
# conf.vm.box = "peru/my_centos-7-x86_64"
# conf.vm.box_version = "20181211.01"
conf.vm.box = "centos/7"
conf.vm.hostname = 'master1.vg'
conf.vm.network "private_network", ip: "192.168.255.100"
conf.vm.provider "virtualbox" do |v|
v.memory = 6144
v.cpus = 2
end
conf.vm.provision "shell", inline: $inline_m1
conf.vm.provision "file", source: "./etc.hosts", destination: "~/etc/hosts"
conf.vm.provision "file", source: "./master1/etc.ansible.hosts", destination: "~/etc/ansible.hosts"
end
config.vm.define "node1" do |conf|
conf.vm.box = "centos/7"
conf.vm.hostname = 'node1.vg'
conf.vm.network "private_network", ip: "192.168.255.101"
conf.vm.provision "file", source: "./etc.hosts", destination: "~/etc/hosts"
conf.vm.provision "shell", inline: $inline_n1_n2
end
config.vm.define "node2" do |conf|
conf.vm.box = "centos/7"
conf.vm.hostname = 'node2.vg'
conf.vm.network "private_network", ip: "192.168.255.102"
conf.vm.provision "file", source: "./etc.hosts", destination: "~/etc/hosts"
conf.vm.provision "shell", inline: $inline_n1_n2
end
end
so it is 1 Master and 2 Nodes. The master is supposed to have ansible installed and access the nodes via ssh. So all machines are up and runnin and I can connect to my master using
vagrant ssh master1
I also have my modified etc/hosts so i can reach master1.vg, node1.vg etc.
But there is one problem. I am supposed to connect via ssh to the nodes from inside the master. but
ssh node1.vg
will not work as permission is denied after asking for a password. according to the documentation the default password should be "vagrant" but this is not the case here. (I guess as the access method is already set to ssh with a key). I have googled for quite a bit as I thought this would be a common question but found no satisfiing answers. Do you have any idea how to make a connection via ssh from master1 vm to one of the node vms?
I've also uploaded the config to a repo (https://github.com/relief-melone/vagrant-ansibletestingsetup)