-
Notifications
You must be signed in to change notification settings - Fork 24
/
Vagrantfile
49 lines (40 loc) · 1.35 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
Vagrant.require_version ">= 2.0.0"
if ENV['IMG'] == "focal64" then
VM_IMG = "ubuntu/focal64"
VM_NAME = "whitefield-focal64"
else
VM_IMG = "ubuntu/bionic64"
VM_NAME = "whitefield-dev"
end
system("
if [ #{ARGV[0]} = 'up' ]; then
if [ ! -f ~/.ssh/id_rsa ]; then
echo '~/.ssh/id_rsa keys does not exist.'
ssh-keygen -t rsa -f ~/.ssh/id_rsa
fi
fi
")
Vagrant.configure("2") do |config|
config.vm.define VM_NAME do |cfg|
cfg.vm.box = VM_IMG
cfg.vm.provider "virtualbox" do |vb|
vb.name = VM_NAME
vb.memory = 4096
vb.cpus = 4
vb.customize ['modifyvm', :id, '--nested-hw-virt', 'on']
end
end
# vagrant@VM_NAME
config.vm.hostname = VM_NAME
# sync directories
whitefield_home = "."
config.vm.synced_folder whitefield_home, "/home/vagrant/whitefield", owner:"vagrant", group:"vagrant"
# copy ssh keys
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "/home/vagrant/.ssh/id_rsa.pub"
config.vm.provision :shell, :inline => "cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys", run: "always"
# copy git config
config.vm.provision :file, source: "~/.gitconfig", destination: "$HOME/.gitconfig"
config.vm.network "private_network", type: "dhcp"
# provision bash scripts
config.vm.provision :shell, inline: "whitefield/scripts/setup.sh"
end