-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
108 lines (92 loc) · 3.33 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version ">= 1.7.2"
options = {
:vendor => 'bepro',
:app => 'forum',
:aliases => [],
:memory => 1024,
:box => 'elao/debian-7-amd64',
:box_version => '~> 1.0.0',
:folders => {
# '../forum' => '/srv/phpBB3'
},
:ansible_playbook => 'ansible/playbook.yml',
:ansible_groups => ['env_dev', 'mysql', 'teamspeak', 'forum'],
:debug => false
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Box
config.vm.box = options[:box]
config.vm.box_version = options[:box_version]
# Hostname
config.vm.hostname = options[:app] + ((options[:vendor] != '') ? '.' + options[:vendor] : '') + '.dev'
# Hosts
if Vagrant.has_plugin?('landrush')
config.landrush.enabled = true
config.landrush.tld = config.vm.hostname
config.landrush.guest_redirect_dns = false
elsif Vagrant.has_plugin?('vagrant-hostmanager')
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
if vm.id
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
end
end
if options[:aliases].any?
config.hostmanager.aliases = ''
for host in options[:aliases]
config.hostmanager.aliases += host + '.' + config.vm.hostname + ' '
end
end
end
# Network
config.vm.network 'private_network', type: 'dhcp'
# Ssh
config.ssh.forward_agent = true
# Folders
options[:folders].each do |host, guest|
config.vm.synced_folder host, guest,
type: 'nfs',
mount_options: ['nolock', 'actimeo=1', 'fsc']
end
# Providers
config.vm.provider :virtualbox do |vb|
vb.name = ((options[:vendor] != '') ? options[:vendor] + '_' : '') + options[:app]
vb.memory = options[:memory]
vb.gui = options[:debug]
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
end
# Git
if File.exists?(File.join(Dir.home, '.gitconfig')) then
config.vm.provision :file do |file|
file.source = '~/.gitconfig'
file.destination = '/home/vagrant/.gitconfig'
end
end
if File.exists?(File.join(Dir.home, '.gitignore')) then
config.vm.provision :file do |file|
file.source = '~/.gitignore'
file.destination = '/home/vagrant/.gitignore'
end
end
# Composer
if File.exists?(File.join(Dir.home, '.composer/auth.json')) then
config.vm.provision :file do |file|
file.source = '~/.composer/auth.json'
file.destination = '/home/vagrant/.composer/auth.json'
end
end
# Provisioners
config.vm.provision 'ansible' do |ansible|
ansible.playbook = options[:ansible_playbook]
ansible.verbose = options[:debug] ? 'vvvv' : false
ansible.groups = {}
for group in options[:ansible_groups]
ansible.groups[group] = ['default']
end
end
end