-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
116 lines (90 loc) · 3.93 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Vagrant.configure("2") do |config|
config.vm.define "servidor" do |subconfig|
subconfig.vm.box = "debian/bullseye64"
subconfig.vm.hostname = "servidor"
subconfig.vm.network :private_network, ip: "192.168.1.10", virtualbox__intnet: "IAWlan"
subconfig.vm.network "forwarded_port", guest: 80, host: 80
subconfig.vm.network :public_network, type: "dhcp"
subconfig.vm.provider :virtualbox do |vb|
vb.name = "servidor"
vb.gui = false
vb.cpus = 4
vb.memory = 4096
end
subconfig.vm.provision "shell", inline: <<-SHELL
apt update && apt install -y docker.io docker-compose samba
mkdir -p /vagrant/developers
echo "[developers]
path = /vagrant/developers
writeable = yes
browseable = yes
" >> /etc/samba/smb.conf
useradd developers
(echo developers; echo developers ) | smbpasswd -s -a developers
chown -R developers:developers /vagrant/developers
chmod 755 /vagrant/developers
cp /vagrant/conf/docker-compose.yml $PWD
docker-compose up -d
apt install -y iptables
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
apt install -y bind9
cp /vagrant/conf/bind/db.abel.org /etc/bind/
cat /vagrant/conf/bind/local.zones >> /etc/bind/named.conf.local
cat /vagrant/conf/bind/named.conf.options > /etc/bind/named.conf.options
systemctl restart named
apt install -y isc-dhcp-server
cp /vagrant/conf/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf
cp /vagrant/conf/dhcp/isc-dhcp-server /etc/default/isc-dhcp-server
systemctl restart isc-dhcp-server
SHELL
subconfig.vm.provision "shell", run: "always", inline: "iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth2 -j MASQUERADE"
subconfig.vm.provision "shell", run: "always", inline: "echo 'nameserver 192.168.1.10' > /etc/resolv.conf"
subconfig.vm.provision "shell", run: "always", inline: "echo 'nameserver 8.8.8.8' >> /etc/resolv.conf"
end
(1..2).each do |n|
config.vm.define "dev#{n}", autostart: false do |dev|
dev.vm.box = "debian/bullseye64"
dev.vm.hostname = "dev#{n}"
dev.vm.network "private_network", type: "dhcp", virtualbox__intnet: "IAWlan"
dev.vm.provider :virtualbox do |vb|
vb.name = "dev#{n}"
vb.cpus = 3
vb.memory = 4096
vb.gui = true
end
dev.vm.provision "shell", inline: <<-SHELL
addgroup developers
useradd -m -c /bin/bash -p dev1 -g developers dev1
useradd -m -c /bin/bash -p dev2 -g developers dev2
cp -rf /etc/skel/ /home/dev1/
chown -R dev1:dev1 /home/dev1
cp -rf /etc/skel/ /home/dev2/
chown -R dev2:dev2 /home/dev2
apt update && apt install -y expect xdotool tasksel cifs-utils psmisc wget apt-transport-https
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
apt update && apt install -y code
mkdir /media/developers
echo "//samba.abel.org/developers /media/developers cifs user=developers,pass=developers 0 0" >> /etc/fstab
mount -av
setxkbmap -layout es
echo "Instalando entorno gráfico, este proceso puede tardar varios minutos..."
tasksel install Debian desktop environment GNOME
cp /vagrant/conf/startx/daemon.conf /etc/gdm3/daemon.conf
SHELL
dev.vm.provision "shell", run: "always", inline: <<-SHELL
for usuario in /home/*; do
if [ -d "$usuario" ]; then
echo "code" >> "$usuario/.profile"
chown $(basename "$usuario"):"$(id -gn $(basename "$usuario"))" "$usuario/.profile"
echo "exec startx" > "$usuario/.xinitrc"
chown $(basename "$usuario"):"$(id -gn $(basename "$usuario"))" "$usuario/.xinitrc"
fi
done
SHELL
end
end
end