This repository has been archived by the owner on May 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
102 lines (88 loc) · 4.1 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
##################################
## ##
## GMdotnet Vagrant LAMP Stack ##
## Version 1.1.5 ##
## ##
##################################
# Import configuration
require 'yaml'
vagrantconfig = YAML.load_file('config/config.yaml')
Vagrant.configure("2") do |config|
vagrantconfig['gmdotnet'].each do |machine|
if machine['host']['enable'] == true
config.vm.define machine['host']['vagrantbox_name'] do |vmhost|
# Machine info
vmhost.vm.box = machine['host']['box']['name']
if machine['host']['box']['version'] != nil
vmhost.vm.box_version = machine['host']['box']['version']
end
vmhost.vm.box_check_update = machine['host']['box']['check_update']
vmhost.vm.hostname = machine['host']['hostname']
# Hostsupdater plugin
if machine['host']['hostsupdate']['enable'] == true
# Hostsupdater aliases
if machine['host']['hostsupdate']['aliases'] != nil
vmhost.hostsupdater.aliases = machine['host']['hostsupdate']['aliases']
end
# Hostsupdater permanent role
if machine['host']['hostsupdate']['permanent'] == true
vmhost.hostsupdater.remove_on_suspend = false
end
## Private IP Network
vmhost.vm.network "private_network", ip: machine['host']['private_ip'], hostsupdater: true
else
## Private IP Network
vmhost.vm.network "private_network", ip: machine['host']['private_ip']
end
## Post message
vmhost.vm.post_up_message = "Welcome to GMdotnet Vagrant LAMP! If you need help just go here https://github.com/gmdotnet/Vagrant-LAMP"
## Shared folders
if machine['host']['share'] != nil
machine['host']['share'].each do |share|
## Shared folders - owner
owner = "vagrant"
group = "vagrant"
if share['folder']['owner'] != nil
owner = share['folder']['owner']
end
if share['folder']['group'] != nil
group = share['folder']['group']
end
vmhost.vm.synced_folder share['folder']['host_folder'], share['folder']['vagrant_folder'], create: true, owner: owner, group: group
end
end
## Rsync folders
if machine['host']['rsync'] != nil
machine['host']['rsync'].each do |rsync|
rsyncoptions = []
rsync['folder']['options'].each do |options|
rsyncoptions.push(options)
end
vmhost.vm.synced_folder rsync['folder']['host_folder'], rsync['folder']['vagrant_folder'], type: "rsync", rsync__args: rsyncoptions
end
end
## Virtualbox options
vmhost.vm.provider "virtualbox" do |vb|
# RAM
vb.memory = machine['host']['ram']
end
## Shell provision
if machine['host']['provision']['script'] == true
vmhost.vm.provision "shell", path: "script/backup_database.sh"
end
## Ansible provision
if machine['host']['provision']['ansible'] == true
vmhost.vm.provision "ansible_local" do |ansible|
ansible.verbose = "vv"
ansible.playbook = "ansible/playbook.yml"
end
end
## -*- end vmhost -*-
end
## -*- end if enable -*-
end
## -*- end machine -*-
end
end