forked from picoCTF/picoCTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
118 lines (103 loc) · 4.22 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
117
118
# -*- mode: ruby -*-
# vi: set ft=ruby :
# TODO:
# - use double quote correctly
require 'etc'
if ENV['SHELL_DISK_SIZE'] then
ENV['VAGRANT_EXPERIMENTAL'] = "disks"
end
# Extract suffix if working directory starts with prefix; otherwise return "".
def compute_auto_name_suffix(prefix = "picoCTF")
dirname = File.basename(Dir.getwd)
return dirname.start_with?(prefix) ? dirname[prefix.length..-1] : ""
end
Vagrant.configure("2") do |config|
config.vm.define "shell", primary: true do |shell|
shell.vm.box = "ubuntu/bionic64"
if ENV['SHELL_DISK_SIZE'] then
shell.vm.disk :disk, size: (ENV['SHELL_DISK_SIZE']), primary: true
end
shell.vm.network "private_network", ip: (ENV['SIP'] || '192.168.2.3'), nic_type: "virtio"
shell.vm.network "forwarded_port", guest: 2376, host: 2223, auto_correct: true
shell.vm.synced_folder ".", "/vagrant", disabled: true
if Vagrant::Util::Platform.windows? then
shell.vm.synced_folder ".", "/picoCTF",
owner: "vagrant", group: "vagrant",
mount_options: ["dmode=775", "fmode=775"]
else
shell.vm.synced_folder ".", "/picoCTF", owner: "vagrant", group: "vagrant"
end
# ensures that SIP/WIP are passed to ansible_local provisioner can use lookup('env',...)
shell.vm.provision "shell" do |s|
s.path = "./scripts/vagrant-env.sh"
s.env = {SIP: (ENV['SIP'] || '192.168.2.3'), WIP: (ENV['WIP'] || '192.168.2.2')}
end
# uses ansible_local so that a user does not need to have ansible installed
shell.vm.provision "ansible_local" do |ansible|
ansible.install = "yes"
ansible.install_mode = "pip"
ansible.pip_install_cmd = "curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | sudo python"
ansible.version = "2.9.11"
ansible.compatibility_mode = "2.0"
ansible.playbook = "site.yml"
ansible.provisioning_path = "/picoCTF/infra_local/"
ansible.inventory_path = "inventory.yml"
ansible.extra_vars = {ansible_connection:"local"}
ansible.verbose = ENV['V']
end
shell.vm.provider "virtualbox" do |vb|
vb.name = "picoCTF-shell-dev" + compute_auto_name_suffix()
# Overridable settings
vb.cpus = [(ENV['J'] || '1').to_i, Etc.nprocessors].min
vb.gui = ENV['G']
vb.memory = (ENV['M'] || '2').to_i * 1024
# Others
vb.customize [
"modifyvm", :id,
"--uartmode1", "file", File.join(Dir.pwd, vb.name + "-console.log")
]
end
end
config.vm.define "web", primary: true do |web|
web.vm.box = "ubuntu/bionic64"
web.vm.network "private_network", ip: (ENV['WIP'] || '192.168.2.2'), nic_type: "virtio"
web.vm.synced_folder ".", "/vagrant", disabled: true
if Vagrant::Util::Platform.windows? then
web.vm.synced_folder ".", "/picoCTF",
owner: "vagrant", group: "vagrant",
mount_options: ["dmode=775", "fmode=775"]
else
web.vm.synced_folder ".", "/picoCTF", owner: "vagrant", group: "vagrant"
end
# ensures that SIP/WIP are passed to ansible_local provisioner can use lookup('env',...)
web.vm.provision "shell" do |s|
s.path = "./scripts/vagrant-env.sh"
s.env = {SIP: (ENV['SIP'] || '192.168.2.3'), WIP: (ENV['WIP'] || '192.168.2.2')}
end
# uses ansible_local so that a user does not need to have ansible installed
web.vm.provision "ansible_local" do |ansible|
ansible.install = "yes"
ansible.install_mode = "pip"
ansible.pip_install_cmd = "curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | sudo python"
ansible.version = "2.9.11"
ansible.compatibility_mode = "2.0"
ansible.playbook = "site.yml"
ansible.provisioning_path = "/picoCTF/infra_local/"
ansible.inventory_path = "inventory.yml"
ansible.extra_vars = {ansible_connection:"local"}
ansible.verbose = ENV['V']
end
web.vm.provider "virtualbox" do |vb|
vb.name = "picoCTF-web-dev" + compute_auto_name_suffix()
# Overridable settings
vb.cpus = [(ENV['J'] || '1').to_i, Etc.nprocessors].min
vb.gui = ENV['G']
vb.memory = (ENV['M'] || '2').to_i * 1024
# Others
vb.customize [
"modifyvm", :id,
"--uartmode1", "file", File.join(Dir.pwd, vb.name + "-console.log")
]
end
end
end