-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
69 lines (67 loc) · 2.37 KB
/
Vagrantfile
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
67
68
69
# -*- mode: ruby -*-
# vim: set ft=ruby :
MACHINES = {
:pg1 => {
:box_name => "Centos",
:ip_addr => '192.168.100.20'
},
:pg2 => {
:box_name => "Centos",
:ip_addr => '192.168.100.21'
},
:dcs1 => {
:box_name => "Centos",
:ip_addr => '192.168.100.30'
},
:dcs2 => {
:box_name => "Centos",
:ip_addr => '192.168.100.31'
},
:dcs3 => {
:box_name => "Centos",
:ip_addr => '192.168.100.32'
},
:nfs => {
:box_name => "Centos",
:ip_addr => '192.168.100.100'
}
}
Vagrant.configure("2") do |config|
MACHINES.each do |boxname, boxconfig|
config.vm.define boxname do |box|
box.vm.box = boxconfig[:box_name]
box.vm.host_name = boxname.to_s
#box.vm.network "forwarded_port", guest: 3260, host: 3260+offset
box.vm.network "private_network", ip: boxconfig[:ip_addr]
box.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "256"]
# Подключаем дополнительные диски
#vb.customize ['createhd', '--filename', second_disk, '--format', 'VDI', '--size', 5 * 1024]
#vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 0, '--device', 1, '--type', 'hdd', '--medium', second_disk]
end
case boxname.to_s
when "pg1"
box.vm.disk :disk, size: "10GB", name: "pg1_pg_data"
box.vm.disk :disk, size: "10GB", name: "pg1_pg_wal"
when "pg2"
box.vm.disk :disk, size: "10GB", name: "pg2_pg_data"
box.vm.disk :disk, size: "10GB", name: "pg2_pg_wal"
when "nfs"
box.vm.disk :disk, size: "10GB", name: "nfs"
end
config.vm.provision "shell" do |s|
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
ssh_pub_key = File.readlines("/home/sirius/.ssh/id_rsa.pub").first.strip
s.inline = <<-SHELL
mkdir -p ~root/.ssh; cp ~vagrant/.ssh/auth* ~root/.ssh
sudo mkdir -p /root/.ssh
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
sed -i '65s/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
SHELL
end
end
end
end