-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
78 lines (56 loc) · 3.23 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
current_dir = File.dirname(File.expand_path(__FILE__))
config_file = YAML.load_file("#{current_dir}/setup/config.yaml")
# Config file validation
config_file.each do |section_key,section_value|
section_value.each do |key,value|
if value.nil? || value == 0
puts "#{section_key}:#{key} is not set in setup/config.yaml. Please check before running again."
abort()
end
end
end
# VM variables
box = "fisheyehq/mage2-ubuntu-16.04-php7.0"
name = config_file['vm']['name']
hostname = config_file['vm']['hostname']
cpus = config_file['vm']['cpus']
memory = config_file['vm']['memory']
ip_address = config_file['vm']['ip_address']
base_url = config_file['magento_setup']['base_url']
base_dir = "/var/www/" + base_url
# Composer auth variables
composer_auth_magentousername = config_file['composer_auth']['magentousername']
composer_auth_magentopassword = config_file['composer_auth']['magentopassword']
composer_auth_githuboauth = config_file['composer_auth']['githuboauth']
# Magento variables
mage_mode = config_file['magento_setup']['mode']
install_sample_data = config_file['magento_setup']['sample_data']
magento_install = config_file['magento_install']
Dir.mkdir("magento") unless File.exists?("magento")
Vagrant.configure(2) do |config|
config.vm.box = box
config.vm.hostname = hostname
config.vm.box_version = ">= 0.0.2"
config.ssh.forward_agent = true
config.vm.provider "virtualbox" do |vb|
vb.name = name
vb.cpus = cpus
vb.memory = memory
end
config.vm.network "private_network", ip: ip_address
config.vm.synced_folder "./setup/", "/vagrant/setup/", type: config_file['vm']['sync_type']
config.vm.synced_folder "./magento/", base_dir, type: config_file['vm']['sync_type']
config.vm.provision :shell, :path => "setup/scripts/initial-config.sh"
config.vm.provision :shell, :path => "setup/scripts/postfix-config.sh", :args => base_url
config.vm.provision :shell, :path => "setup/scripts/composer-config.sh", :args => "#{composer_auth_magentousername} #{composer_auth_magentopassword} #{composer_auth_githuboauth}", :privileged => false
config.vm.provision :shell, :path => "setup/scripts/nginx-config.sh", :args => "#{base_url} #{mage_mode}"
if magento_install['install'] == 'y'
config.vm.provision :shell, :path => "setup/scripts/magento-setup.sh", :args => "#{base_url} #{install_sample_data}", :privileged => false
config.vm.provision :shell, :path => "setup/scripts/magento-install.sh", :args => "#{magento_install['admin_firstname']} #{magento_install['admin_lastname']} #{magento_install['admin_email']} #{magento_install['admin_user']} #{magento_install['admin_password']} #{base_url} #{magento_install['backend_frontname']} #{magento_install['language']} #{magento_install['currency']} #{magento_install['timezone']} #{magento_install['session_save']} #{magento_install['use_rewrites']} #{magento_install['default_country']} #{magento_install['admin_session_lifetime']} #{mage_mode}", :privileged => false
end
config.vm.provision :shell, :path => "setup/scripts/cron-config.sh", :args => base_dir
config.vm.provision :shell, :path => "setup/scripts/final-config.sh", :args => "#{base_dir} #{ip_address} #{base_url}"
end