-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
55 lines (47 loc) · 1.87 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
## Define some app-specific stuff to be used later during provisioning: ##
app_vars = {
APPNAME: 'MyApp',
DBNAME: 'symfony',
DBUSER: 'vagrant',
DBPASSWORD: 'vagrant',
DBTYPE: 'mysql' # 'mysql' or 'postgresql'
}
# ansible_verbosity = 'vvvv'
##########################################################################
#Fix for people with strange locale settings
ENV.keys.each {|k| k.start_with?('LC_') && ENV.delete(k)}
def host_box_is_unixy?
(RUBY_PLATFORM !~ /cygwin|mswin|mingw|bccwin|wince|emx/)
end
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
verbosity_arg = if defined? ansible_verbosity then ansible_verbosity else '' end
if host_box_is_unixy?
config.vm.synced_folder "./", "/vagrant", type: "nfs"
config.vm.provision :ansible do |ansible|
ansible.playbook = 'provisioning/site.yml'
ansible.extra_vars = app_vars
ansible.verbose = verbosity_arg
end
else
config.vm.synced_folder "./", "/vagrant", type: "smb", mount_options: ['ip=192.168.50.1'] #host side of :private_network
extra_vars_arg = '{' + app_vars.map{|k,v| '"' + k.to_s + '":"' + v.to_s + '"'}.join(',') + '}'
config.vm.provision :shell, :inline => <<-END
set -e
if ! which ansible-playbook ; then
echo "Windows host environment: the devbox will install Ansible and self-provision itself" >&2
sudo apt-get update
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get -y install ansible
fi
PYTHONUNBUFFERED=1 ansible-playbook --connection=local -i "[default] $(hostname)," \\
--extra-vars='#{ extra_vars_arg }' #{ verbosity_arg.empty? ? '' : '-'+ansible_verbosity } /vagrant/provisioning/site.yml
END
end
config.vm.network "forwarded_port", guest: 80, host: 8181
config.vm.network "private_network", ip: "192.168.50.4"
end