@@ -78,8 +78,6 @@ Vagrant.configure('2') do |config|
78
78
wordpress_sites . each_pair do |name , site |
79
79
config . vm . synced_folder local_site_path ( site ) , remote_site_path ( name , site ) , owner : 'vagrant' , group : 'www-data' , mount_options : [ 'dmode=776' , 'fmode=775' ]
80
80
end
81
- config . vm . synced_folder ANSIBLE_PATH , ANSIBLE_PATH_ON_VM , mount_options : [ 'dmode=755' , 'fmode=644' ]
82
- config . vm . synced_folder File . join ( ANSIBLE_PATH , 'bin' ) , bin_path , mount_options : [ 'dmode=755' , 'fmode=755' ]
83
81
else
84
82
if !Vagrant . has_plugin? 'vagrant-bindfs'
85
83
fail_with_message "vagrant-bindfs missing, please install the plugin with this command:\n vagrant plugin install vagrant-bindfs"
@@ -94,8 +92,12 @@ Vagrant.configure('2') do |config|
94
92
end
95
93
end
96
94
97
- provisioner = Vagrant ::Util ::Platform . windows? ? :ansible_local : :ansible
98
- provisioning_path = Vagrant ::Util ::Platform . windows? ? ANSIBLE_PATH_ON_VM : ANSIBLE_PATH
95
+ config . vm . synced_folder ANSIBLE_PATH , ANSIBLE_PATH_ON_VM , mount_options : [ 'dmode=755' , 'fmode=644' ]
96
+ config . vm . synced_folder File . join ( ANSIBLE_PATH , 'bin' ) , bin_path , mount_options : [ 'dmode=755' , 'fmode=755' ]
97
+
98
+ provisioner = local_provisioning? ? :ansible_local : :ansible
99
+ provisioning_path = local_provisioning? ? ANSIBLE_PATH_ON_VM : ANSIBLE_PATH
100
+
99
101
config . vm . provision provisioner do |ansible |
100
102
if Vagrant ::Util ::Platform . windows?
101
103
ansible . install_mode = 'pip'
@@ -155,6 +157,10 @@ Vagrant.configure('2') do |config|
155
157
156
158
end
157
159
160
+ def local_provisioning?
161
+ Vagrant ::Util ::Platform . windows? || !which ( 'ansible-playbook' ) || ENV [ 'FORCE_ANSIBLE_LOCAL' ]
162
+ end
163
+
158
164
def local_site_path ( site )
159
165
File . expand_path ( site [ 'local_path' ] , ANSIBLE_PATH )
160
166
end
180
186
def remote_site_path ( site_name , site )
181
187
"/srv/www/#{ site_name } /#{ site [ 'current_path' ] || 'current' } "
182
188
end
189
+
190
+ def which ( cmd )
191
+ exts = ENV [ 'PATHEXT' ] ? ENV [ 'PATHEXT' ] . split ( ';' ) : [ '' ]
192
+
193
+ ENV [ 'PATH' ] . split ( File ::PATH_SEPARATOR ) . each do |path |
194
+ exts . each do |ext |
195
+ exe = File . join ( path , "#{ cmd } #{ ext } " )
196
+ return exe if File . executable? ( exe ) && !File . directory? ( exe )
197
+ end
198
+ end
199
+
200
+ nil
201
+ end
0 commit comments