This repository has been archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
131 lines (108 loc) · 4.38 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# -*- mode: ruby -*-
# vi: set ft=ruby :
CHEF_VM_NAME = 'zf2tutorial-zf2'
CHEF_VM_HOSTNAME = 'zf2tutorial.zf2.ldev'
CHEF_VM_ENVIRONMENT = 'development'
CHEF_CLIENT_VERSION = '13.12.3'
VM_IP_ADDRESS = '10.9.8.8'
VAGRANTFILE_API_VERSION = '2'
VAGRANT_MIN_VERSION = '1.7.4'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Check Vagrant version
if Vagrant::VERSION < VAGRANT_MIN_VERSION
puts "FATAL: Cookbook depends on Vagrant #{VAGRANT_MIN_VERSION} or higher."
exit
end
# Plugin-specific configurations
# Detects vagrant cachier plugin
if Vagrant.has_plugin?('vagrant-cachier')
puts 'INFO: Vagrant-cachier plugin detected. Optimizing caches.'
config.cache.auto_detect = true
config.cache.enable :chef
config.cache.enable :apt
else
puts 'WARN: Vagrant-cachier plugin not detected. Continuing unoptimized.'
end
# Detects vagrant omnibus plugin
if Vagrant.has_plugin?('vagrant-omnibus')
puts 'INFO: Vagrant-omnibus plugin detected.'
config.omnibus.chef_version = CHEF_CLIENT_VERSION
#config.omnibus.chef_version = :latest
else
puts "FATAL: Vagrant-omnibus plugin not detected. Please install the plugin with\n 'vagrant plugin install vagrant-omnibus' from any other directory\n before continuing."
exit
end
# Detects vagrant berkshelf plugin
if Vagrant.has_plugin?('berkshelf')
puts 'INFO: Vagrant-berkshelf plugin detected.'
# The path to the Berksfile to use with Vagrant Berkshelf
config.berkshelf.berksfile_path = './Berksfile'
config.berkshelf.enabled = true
else
puts "FATAL: Vagrant-berkshelf plugin not detected. Please install the plugin with\n 'vagrant plugin install vagrant-berkshelf' from any other directory\n before continuing."
exit
end
# Detects vagrant hostmanager plugin
if Vagrant.has_plugin?('vagrant-hostmanager')
puts 'INFO: Vagrant-hostmanager plugin detected.'
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.aliases = [CHEF_VM_HOSTNAME]
else
puts "WARN: Vagrant-hostmanager plugin not detected. Please install the plugin with\n 'vagrant plugin install vagrant-hostmanager' from any other directory\n before continuing."
end
# Add additional virtualhost aliases
Dir[Pathname(__FILE__).dirname.join('data_bags','virtualhosts','*.json')].each do |databagfile|
config.hostmanager.aliases << JSON.parse(Pathname(__FILE__).dirname.join('data_bags','virtualhosts',databagfile).read)['development']['server_name']
JSON.parse(Pathname(__FILE__).dirname.join('data_bags','virtualhosts',databagfile).read)['development']['server_aliases'].each do |serveralias|
config.hostmanager.aliases << serveralias
end
end
# rmemove duplicate
config.hostmanager.aliases = config.hostmanager.aliases.uniq!
# vm config
config.vm.hostname = CHEF_VM_HOSTNAME
# config.vm.box = 'opscode-ubuntu-14.04'
# config.vm.box_url = 'http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box'
# config.vm.box = 'opscode-ubuntu-16.04'
# config.vm.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box'
config.vm.box = 'bento/ubuntu-16.04'
config.vm.network :private_network, :ip => VM_IP_ADDRESS
config.vm.provider :virtualbox do |vb|
# Give enough horsepower to build without taking all day.
vb.customize [
'modifyvm', :id,
'--memory', '1024',
'--cpus', '2',
]
end
# Enable SSH agent forwarding for git clones
config.ssh.forward_agent = true
# provision config
config.vm.provision :chef_zero do |chef|
chef.cookbooks_path = 'cookbooks'
chef.data_bags_path = 'data_bags'
chef.environments_path = 'environments'
chef.roles_path = 'roles'
chef.nodes_path = 'nodes'
chef.synced_folder_type = :nfs
chef.node_name = CHEF_VM_NAME
chef.environment = CHEF_VM_ENVIRONMENT
chef.log_level = :info
# chef.log_level = :debug
chef.verbose_logging = true
chef.json = {
:mysql => {
:server_root_password => 'rootpass',
:server_debian_password => 'debpass',
:server_repl_password => 'replpass'
}
}
chef.run_list = %w(
recipe[zf2::servernode]
recipe[zf2::development]
)
end
end