-
Notifications
You must be signed in to change notification settings - Fork 17
/
Vagrantfile
94 lines (73 loc) · 4.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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
ansible_vars = YAML.load_file("provisioning/vars.yml")
app_name = ansible_vars["nodejs_app_name"]
app_directory = ansible_vars["nodejs_app_install_dir"]
app_start_script = ansible_vars["nodejs_app_start_script"]
# Check for the existence of the 'VM_HOST_TCP_PORT' environment variable. If it
# doesn't exist and 'nodejs_app_tcp_port' is defined in vars.yml then use that
# port. Failing that use defaults provided in this file.
host_tcp_port = ENV["VM_HOST_TCP_PORT"] || ansible_vars["nodejs_app_tcp_port"] || 8081
guest_tcp_port = ansible_vars["nodejs_app_tcp_port"] || 8081
# By default this VM will use 2 processor cores and 2GB of RAM. The 'VM_CPUS' and
# "VM_RAM" environment variables can be used to change that behaviour.
cpus = ENV["VM_CPUS"] || 2
ram = ENV["VM_RAM"] || 2048
Vagrant.configure(2) do |config|
config.vm.box = "inclusivedesign/fedora27"
# Your working directory will be synced to /home/vagrant/sync in the VM.
config.vm.synced_folder ".", "#{app_directory}"
# Mounts node_modules in /var/tmp to work around issues in the VirtualBox shared folders
config.vm.provision "shell", run: "always", inline: <<-SHELL
sudo mkdir -p /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
sudo chown vagrant:vagrant -R /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
sudo mount -o bind /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
SHELL
# List additional directories to sync to the VM in your "Vagrantfile.local" file
# using the following format:
# config.vm.synced_folder "../path/on/your/host/os/your-project", "/home/vagrant/sync/your-project"
if File.exist? "Vagrantfile.local"
instance_eval File.read("Vagrantfile.local"), "Vagrantfile.local"
end
# Port forwarding takes place here. The 'guest' port is used inside the VM
# whereas the 'host' port is used by your host operating system.
config.vm.network "forwarded_port", guest: guest_tcp_port, host: host_tcp_port, protocol: "tcp",
auto_correct: true
# Port 19531 is needed so logs can be viewed using systemd-journal-gateway
#config.vm.network "forwarded_port", guest: 19531, host: 19531, protocol: "tcp",
# auto_correct: true
config.vm.hostname = app_name
config.vm.provider :virtualbox do |vm|
vm.customize ["modifyvm", :id, "--memory", ram]
vm.customize ["modifyvm", :id, "--cpus", cpus]
vm.customize ["modifyvm", :id, "--vram", "256"]
vm.customize ["modifyvm", :id, "--accelerate3d", "off"]
vm.customize ["modifyvm", :id, "--audio", "null", "--audiocontroller", "ac97"]
vm.customize ["modifyvm", :id, "--ioapic", "on"]
vm.customize ["setextradata", "global", "GUI/SuppressMessages", "all"]
end
config.vm.provision "shell", inline: <<-SHELL
sudo ansible-galaxy install -fr /home/vagrant/sync/provisioning/requirements.yml
sudo PYTHONUNBUFFERED=1 ansible-playbook /home/vagrant/sync/provisioning/playbook.yml --tags="install,configure" --inventory="localhost ansible_connection=local,"
SHELL
# Using config.vm.hostname to set the hostname on Fedora VMs seems to remove the string
# "localhost" from the first line of /etc/hosts. This script reinserts it if it's missing.
# https://github.com/mitchellh/vagrant/pull/6203
config.vm.provision "shell",
inline: "/usr/local/bin/edit-hosts.sh",
run: "always"
# The Vagrant box is configured with packagekit service disabled and masked.
# Packagekit is needed by the linux implementation of the DeviceReporter -- re-enable
# here. If the service is running, the inline script below is a no-op.
# Note: unfortunately, the output on the command line is:
# default: Removed /etc/systemd/system/packagekit.service
# But, that actually means that the service is up and running. What it is
# saying is that the service has been unlinked from /dev/null, i.e. working.
config.vm.provision "shell",
run: "always",
inline: <<-SHELL
sudo systemctl unmask packagekit.service
sudo systemctl start packagekit.service
SHELL
end