1- %w( vagrant-hostmanager vagrant-auto_network vagrant-nfs_guest ) . each do |plugin |
1+ %w( vagrant-hostmanager vagrant-auto_network ) . each do |plugin |
22 unless Vagrant . has_plugin? ( plugin )
33 raise 'In order to use this box, you must install plugin: ' + plugin
44 end
55end
66
7+ mount_plugin = nil
8+
9+ %w( vagrant-unison2 vagrant-nfs_guest ) . each do |plugin |
10+ if Vagrant . has_plugin? ( plugin )
11+ mount_plugin = plugin
12+ break
13+ end
14+ end
15+
16+ if mount_plugin . nil?
17+ raise 'No efficient shared mount plugins found, please install vagrant-unison2 or vagrant-nfs_guest'
18+ end
19+
720require_relative 'vagrant/inline/config'
8- require_relative 'vagrant/inline/nfs-plugin'
921
1022# Define Vagrantfile configuration options
1123VagrantApp ::Config . option ( :varnish , false ) # If varnish needs to be enabled
@@ -24,7 +36,11 @@ VagrantApp::Config.option(:varnish, false) # If varnish needs to be enabled
2436 . option ( :group , 'app' ) # Group name for share
2537 . option ( :uid , Process . euid ) # User ID for mapping
2638 . option ( :gid , Process . egid ) # Group ID for mapping
27- . option ( :directory , 'server' ) # Directory to be used as mount on host machine
39+ . option ( :directory , 'server' ) # Directory to be used as mount on host machine for NFS guest plugin
40+ . option ( :unison_host , 'project' ) # Directory for project code
41+ . option ( :unison_guest , 'project' ) # Directory for project code
42+ . option ( :unison_ignore , 'Name {.DS_Store,.git}' ) # Unison ignore pattern
43+ . option ( :unison_manage_permissions , false ) # Unison manage permissions
2844 . option ( :network , '33.33.33.0/24' ) # Directory to be used as mount on host machine
2945
3046Vagrant . configure ( "2" ) do |config |
@@ -78,12 +94,11 @@ Vagrant.configure("2") do |config|
7894 # Disable default /vagrant mount as we use custom user for box
7995 config . vm . synced_folder '.' , '/vagrant/' , disabled : true
8096
81- config . vm . synced_folder box_config . get ( :directory ) , '/data/web' , type : 'nfs_guest' , create : true ,
82- linux__nfs_options : %w( rw no_subtree_check all_squash insecure async ) ,
83- map_uid : box_config . get ( :uid ) . to_s ,
84- map_gid : box_config . get ( :gid ) . to_s ,
85- owner : box_config . get ( :user ) ,
86- group : box_config . get ( :group )
97+ if mount_plugin == 'vagrant_nfs-guest'
98+ project_dir = 'magento2'
99+ else
100+ project_dir = box_config . get ( :unison_guest )
101+ end
87102
88103 box_config . shell_list . each do |file |
89104 config . vm . provision 'shell' , path : 'vagrant/provisioning/' + file , env : {
@@ -94,7 +109,8 @@ Vagrant.configure("2") do |config|
94109 VAGRANT_HOSTNAME : box_config . get ( :hostname ) ,
95110 VAGRANT_FPM_SERVICE : box_config . flag? ( :php7 ) ? 'php7.0-fpm' : 'php5-fpm' ,
96111 VAGRNAT_PHP_ETC_DIR : box_config . flag? ( :php7 ) ? '/etc/php/7.0/' : '/etc/php5/' ,
97- VAGRNAT_PHP_PACKAGE_PREFIX : box_config . flag? ( :php7 ) ? 'php7.0' : 'php5'
112+ VAGRNAT_PHP_PACKAGE_PREFIX : box_config . flag? ( :php7 ) ? 'php7.0' : 'php5' ,
113+ VAGRANT_PROJECT_DIR : box_config . get ( :unison_guest )
98114 }
99115 end
100116
@@ -107,6 +123,24 @@ Vagrant.configure("2") do |config|
107123 node . vm . hostname = box_config . get ( :hostname )
108124 node . vm . network :private_network , auto_network : true
109125 node . hostmanager . aliases = box_config . get ( :domains )
126+
127+
128+ if mount_plugin == 'vagrant_nfs-guest'
129+ node . vm . synced_folder box_config . get ( :directory ) , '/data/web' , type : 'nfs_guest' , create : true ,
130+ linux__nfs_options : %w( rw no_subtree_check all_squash insecure async ) ,
131+ map_uid : box_config . get ( :uid ) . to_s ,
132+ map_gid : box_config . get ( :gid ) . to_s ,
133+ owner : box_config . get ( :user ) ,
134+ group : box_config . get ( :group )
135+ else
136+ config . unison . host_folder = box_config . get ( :unison_host )
137+ config . unison . guest_folder = box_config . get ( :unison_guest )
138+ config . unison . ignore = box_config . get ( :unison_ignore )
139+ config . unison . perm = box_config . flag? ( :unison_manage_permissions ) ? 1 : 0
140+ config . unison . ssh_host = box_config . get ( :hostname )
141+ config . unison . ssh_user = 'app'
142+ config . unison . ssh_port = 22
143+ end
110144 end
111145
112146end
0 commit comments