-
Notifications
You must be signed in to change notification settings - Fork 14
/
Vagrantfile_bck
66 lines (58 loc) · 1.81 KB
/
Vagrantfile_bck
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
61
62
63
64
65
66
Vagrant.configure("2") do |config|
servers=[
{
:host => "centos1",
:hostname => "centos1.lab.com",
:box => "centos/7",
:ip => "192.168.56.105",
:ssh_port => '2228'
},
{
:host => "centos2",
:hostname => "centos2.lab.com",
:box => "centos/7",
:ip => "192.168.56.106",
:ssh_port => '2229'
},
{
:host => "ubuntu1",
:hostname => "ubuntu1.lab.com",
:box => "bento/ubuntu-22.04",
:ip => "192.168.56.107",
:ssh_port => '2230'
},
{
:host => "ubuntu2",
:hostname => "ubuntu2.lab.com",
:box => "bento/ubuntu-18.04",
:ip => "192.168.56.108",
:ssh_port => '2231'
},
{
:host => "rocky1",
:hostname => "rocky1.lab.com",
:box => "rockylinux/8",
:ip => "192.168.56.109",
:ssh_port => '2232'
},
]
servers.each do |machine|
config.vm.define machine[:host] do |node|
node.vm.box = machine[:box]
node.vm.hostname = machine[:hostname]
node.vm.synced_folder '.', '/vagrant', disabled: true
node.vm.network :private_network, ip: machine[:ip]
node.vm.network "forwarded_port", guest: 22, host: machine[:ssh_port], id: "ssh"
node.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 1024]
v.customize ["modifyvm", :id, "--cpus", 1]
v.customize ["modifyvm", :id, "--name", machine[:hostname]]
end
end
end
id_rsa_key_pub = File.read(File.join(Dir.home, ".ssh", "id_rsa.pub"))
config.vm.provision :shell,
:inline => "echo 'appending SSH public key to ~vagrant/.ssh/authorized_keys' && echo '#{id_rsa_key_pub }' >> /home/vagrant/.ssh/authorized_keys && chmod 600 /home/vagrant/.ssh/authorized_keys"
config.ssh.insert_key = false
config.vbguest.auto_update = false
end