This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
64 lines (46 loc) · 2.02 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "phpacker-trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.hostname = "phpdevbox"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
if Vagrant::Util::Platform.windows?
config.vm.synced_folder ".", "/vagrant", type: "nfs"
if File.exists?(File.join(Dir.home, ".ssh", "id_rsa"))
# Read local machine's SSH Key (~/.ssh/id_rsa)
ssh_key = File.read(File.join(Dir.home, ".ssh", "id_rsa"))
# Copy it to VM as the /home/vagrant/.ssh/id_rsa key
config.vm.provision :shell, :inline => "echo 'Windows-specific: Copying local SSH Key to VM for provisioning...' && mkdir -p /home/vagrant/.ssh && echo '#{ssh_key}' > /home/vagrant/.ssh/id_rsa && chmod 600 /home/vagrant/.ssh/id_rsa && chown vagrant /home/vagrant/.ssh/id_rsa"
else
# Else, throw a Vagrant Error. Cannot successfully startup on Windows without an SSH Key!
raise Vagrant::Errors::VagrantError, "\n\nERROR: SSH Key not found at ~/.ssh/id_rsa (required on Windows)."
end
# Run ansible using vagrant as host
config.vm.provision :shell, path: "provisioning/windows.sh"
else
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provision :ansible do |ansible|
ansible.playbook = "provisioning/site.yml"
ansible.limit = "all"
end
end
if Vagrant.has_plugin?("vagrant-hostsupdater")
# Require YAML module
require 'yaml'
# Read YAML file with box details
sites = YAML.load_file('provisioning/variables/nginx.yml')
domains = []
# Iterate through entries in YAML file
sites['nginx_sites'].each do |site|
domains.push(site['site']['server_name'])
end
config.hostsupdater.aliases = domains
end
config.ssh.forward_agent = true
end