forked from afup/haphpy-birthday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
executable file
·87 lines (75 loc) · 3.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##################################################
# Generated by phansible.com
##################################################
#If your Vagrant version is lower than 1.5, you can still use this provisioning
#by commenting or removing the line below and providing the config.vm.box_url parameter,
#if it's not already defined in this Vagrantfile. Keep in mind that you won't be able
#to use the Vagrant Cloud and other newer Vagrant features.
Vagrant.require_version ">= 1.5"
# Check to determine whether we're on a windows or linux/os-x host,
# later on we use this to launch ansible in the supported way
# source: https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable? exe
}
end
return nil
end
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |v|
v.name = "haphpy-birthday"
v.customize [
"modifyvm", :id,
"--name", "haphpy-birthday",
"--memory", 1024,
"--natdnshostresolver1", "on",
"--cpus", 1,
]
end
config.vm.box = "debian/jessie64"
config.vm.network :private_network, ip: "192.168.33.99"
config.ssh.forward_agent = true
# Hostname
config.vm.hostname = 'haphpy-birthday.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 item in options[:aliases]
config.hostmanager.aliases += item + '.' + config.vm.hostname + ' '
end
end
end
#############################################################
# Ansible provisioning (you need to have ansible installed)
#############################################################
if which('ansible-playbook')
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all'
ansible.extra_vars = {
private_interface: "192.168.33.99",
hostname: "haphpy-birthday"
}
end
else
config.vm.provision :shell, path: "ansible/windows.sh", args: ["haphpy-birthday"]
end
config.vm.synced_folder "./", "/vagrant", type: "nfs"
end