-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
61 lines (51 loc) · 1.79 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
if File.exists? ('vagrant.yml')
settings = YAML.load_file 'vagrant.yml'
else
settings = {}
end
memory = settings['memory'] || 8192
cpus = settings['cpus'] || 4
name = settings['name'] || 'vagrant.bw'
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
#vb.gui = true
# Number of CPUs
vb.cpus = cpus
# Memory
vb.memory = memory
# Name in VirtualBox Gui
vb.name = name
end
config.vm.define name
config.vm.synced_folder './', '/vagrant', type: 'rsync', disabled: true
# port forwarding
config.vm.network "forwarded_port", guest: 22, host: 10022, auto_correct: false
config.vm.network "forwarded_port", guest: 80, host: 10080, auto_correct: false
config.vm.network "forwarded_port", guest: 443, host: 10443, auto_correct: false
config.vm.network "forwarded_port", guest: 1883, host: 11883, auto_correct: false
config.vm.provision "shell", inline: <<-SHELL
DEBIAN_FRONTEND=noninteractive apt-get update --quiet
DEBIAN_FRONTEND=noninteractive apt-get upgrade --quiet --yes
DEBIAN_FRONTEND=noninteractive apt-get install --quiet --yes --no-install-recommends \
file \
sudo
DEBIAN_FRONTEND=noninteractive apt-get autoremove --yes
DEBIAN_FRONTEND=noninteractive apt-get clean
SHELL
config.vm.provision "shell" do |s|
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
s.inline = <<-SHELL
addgroup --quiet --gid 11000 bborbe
adduser --quiet --uid 11000 --gid 11000 --gecos "" --disabled-password --shell /bin/bash bborbe
mkdir -p /home/bborbe/.ssh
echo #{ssh_pub_key} > /home/bborbe/.ssh/authorized_keys
chown -R bborbe /home/bborbe
chmod -R go= /home/bborbe
echo "bborbe ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/bborbe
SHELL
end
end