This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile_ubu
60 lines (51 loc) · 1.45 KB
/
Vagrantfile_ubu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Define virtualbox boxes
boxes = [
{
:name => "srv-ubuntu14",
:eth1 => "192.168.50.100",
:mem => "1024",
:cpu => "1",
:os => "ubuntu/trusty64",
},
{
:name => "srv-ubuntu16",
:eth1 => "192.168.50.101",
:mem => "1024",
:cpu => "1",
:os => "ubuntu/xenial64",
}
]
# Lets check what kind of SSH key you have generated and upload it on vm
rsa_key = File.expand_path('~') + "/.ssh/id_rsa.pub"
dsa_key = File.expand_path('~') + "/.ssh/id_dsa.pub"
if FileTest.exists?(rsa_key)
key = rsa_key
elsif FileTest.exists?(dsa_key)
key = dsa_key
end
Vagrant.configure(2) do |config|
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.box = opts[:os]
#config.ssh.insert_key = false
ssh_public_key = File.read("#{key}")
config.vm.network "private_network", ip: opts[:eth1]
config.vm.hostname = opts[:name]
config.vm.provider "virtualbox" do |v|
v.memory = opts[:mem]
v.cpus = opts[:cpu]
v.name = opts[:name]
end
config.vm.provision "shell", inline: <<-SHELL
echo "#{ssh_public_key}" >> /home/ubuntu/.ssh/authorized_keys
SHELL
#config.vm.provision :ansible do |ansible|
# ansible.playbook = "pre_provision.yml"
# ansible.inventory_path = "development/hosts"
# ansible.verbose = "v"
#end
end
end
end