-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
121 lines (101 loc) · 3.73 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
119
120
121
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Prerequisites validation
## Vagrant version
Vagrant.require_version ">= 1.7.4"
$forwarded_ports = { 80 => 80, 443 => 443 }
# Make sure the vagrant-ignition plugin is installed
#required_plugins = %w{ vagrant-winnfsd }
required_plugins = %w{ }
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of one or more plugins has failed. Aborting."
end
end
set_environment_variables = <<SCRIPT
cat << EOF > /etc/profile.d/myvars.sh
# environment variables.
# change default docker-compose load file name
export COMPOSE_FILE=docker-compose.yml
alias dc='docker-compose'
EOF
SCRIPT
latest_docker_install_script = <<SCRIPT
DOCKER_VERSION=18.09.2
DOCKER_COMPOSE_VERSION=1.23.2
docker version
/etc/init.d/docker restart $DOCKER_VERSION
wget -q -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m`
mv docker-compose-`uname -s`-`uname -m` /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
chown root:root /opt/bin/docker-compose
SCRIPT
fix_dns_use_ipv6 = <<SCRIPT
sed -i "s/^nameserver 8.8.8.8$/#nameserver 8.8.8.8/g" /etc/resolv.conf
sed -i "s/^nameserver 8.8.4.4$/#nameserver 8.8.4.4/g" /etc/resolv.conf
SCRIPT
max_inotify = <<SCRIPT
cat << EOF > /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
fs.inotify.max_user_watches=524288
EOF
sysctl -p||true
SCRIPT
ssh_path_init = <<SCRIPT
cat << EOF > /home/bargee/.bash_profile
if [ -f "/home/bargee/.bashrc" ]; then
source "/home/bargee/.bashrc"
fi
cd /vagrant
EOF
SCRIPT
run_docker_compose = <<SCRIPT
cd /vagrant
docker-compose down
time docker-compose build
docker-compose up -d
SCRIPT
module VagrantPlugins
module GuestLinux
class Plugin < Vagrant.plugin("2")
guest_capability("linux", "change_host_name") { Cap::ChangeHostName }
guest_capability("linux", "configure_networks") { Cap::ConfigureNetworks }
end
end
end
Vagrant.configure("2") do |config|
config.vm.define "barge"
config.vm.box = "ailispaw/barge"
$forwarded_ports.each do |guest, host|
config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true
end
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
config.vm.synced_folder ".", "/vagrant"
# for NFS synced folder
# config.vm.network "private_network", ip: "192.168.33.10"
# config.vm.synced_folder "../nfs", "/nfs", type: "nfs",
# disabled: false, create: true,
# 19m
# mount_options: ["nolock", "vers=3", "udp", "noatime", "actimeo=1"]
# 12m
# mount_options: ["nolock", "vers=3", "udp", "noatime", "actimeo=120", "noacl", "nocto", "rsize=32768", "wsize=32768"]
# for RSync synced folder
# config.vm.synced_folder ".", "/vagrant", type: "rsync",
# disabled: false, create: true, owner: "bargee", group: "bargees",
# rsync__chown: false, rsync__auto: true, rsync__rsync_ownership: true,
# rsync__args: ["--verbose", "--archive", "--delete", "--copy-links"]
config.vm.provision :shell, :inline => latest_docker_install_script
config.vm.provision :shell, :inline => ssh_path_init
config.vm.provision :shell, :inline => fix_dns_use_ipv6, run: "always"
config.vm.provision :shell, :inline => max_inotify
config.vm.provision :shell, :inline => set_environment_variables, run: "always"
# config.vm.provision :shell, :inline => run_docker_compose, run: "always"
end