-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
115 lines (84 loc) · 3.01 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
#
# Jekyll Development Box for perfSONAR Web Site
#
name = "ps-site-dev"
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-vbguest")
# Don't allow upgrades; the box has what it has.
config.vbguest.auto_update = false
end
# Basic configuration
config.vm.provider "virtualbox" do |vbox|
# The default E1000 has a security vulerability.
vbox.default_nic_type = "82543GC"
vbox.cpus = 2
vbox.memory = 2048
config.vm.box = "bento/centos-7"
config.vm.hostname = name
end
config.vm.provision "setup", type: "shell", run: "once", inline: <<-SHELL
yum -y install epel-release
yum -y update
SHELL
#
# User Account, Shared Folders and Local Storage
#
acct = Etc.getpwnam(Etc.getlogin)
group = Etc.getgrgid(acct.gid)
home_dir = acct.dir
config.vm.provision "account", type: "shell", run: "once", inline: <<-SHELL
set -e
mkdir -p '#{home_dir}'
yum -y install '#{acct.shell}'
if ! getent group "#{group.name}"
then
groupadd --gid "#{group.gid}" "#{group.name}"
fi
id '#{acct.name}' >/dev/null 2>&1 \
|| useradd \
--no-create-home \
--comment '#{acct.gecos}' \
--home-dir '#{home_dir}' \
--shell '#{acct.shell}' \
--uid '#{acct.uid}' \
--gid '#{group.gid}' \
'#{acct.name}'
# Local Storage
install -d -D -o '#{acct.uid}' -g '#{acct.gid}' -m 770 '/local/#{acct.name}'
# Grant frictionless sudo
SUDOERS="/etc/sudoers.d/#{acct.name}"
echo "#{acct.name} ${NEW_USER} ALL= (ALL) NOPASSWD:ALL" > "${SUDOERS}"
chmod 440 "${SUDOERS}"
# Install anything the user's custom package list says it wants
if [ -e '#{home_dir}/.packages' ]
then
xargs -r yum -y install < '#{home_dir}/.packages'
fi
SHELL
config.vm.synced_folder "#{acct.dir}/", home_dir,
automount: false,
mount_options: ["uid=#{acct.uid}", "gid=#{acct.gid}"],
SharedFoldersEnableSymlinksCreate: true
#
# Jekyll
#
vagrantfile_dir = File.dirname(__FILE__)
config.vm.provision "jekyll", type: "shell", run: "once", inline: <<-SHELL
set -e
# Ruby version manager (https://rvm.io)
KS="--keyserver hkp://pgp.mit.edu"
gpg2 ${KS} --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB \
|| ${KS} gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.7
# Jekyll (https://jekyllrb.com)
gem install bundler jekyll
# Everything else
yum -y install git
# Final setup
su '#{acct.name}' -c "make -C '#{vagrantfile_dir}' setup"
SHELL
end
# -*- mode: ruby -*-
# vi: set ft=ruby :