Open mlander opened 8 years ago
I'm all for this providing it's developed with #253 in mind.
I've got a custom play that handles (almost) this layout currently. The major difference is I'm installing vlad via composer so the vlad directory ends up in vendor
. To work with your structure above, you'd just need to change the synced folder paths.
I agree that it'd be nice to support this. But would it be better to wait for #305 first?
relevant part of vlad_settings:
host_synced_folder: "../../.."
aux_synced_folder: "../../../vlad_aux"
# Change the docroot to match what composer builds while we wait for vlad
# issue #284
vlad_custom_play: true
vlad_custom_play_path: "../../../vlad_custom/"
webserver_custom_docroot: 'web'
# Tweaks
add_index_file: false
vlad_custom play:
---
- hosts: all
user: vagrant
vars_files:
- "../vendor/hashbangcode/vlad/vlad_guts/merged_user_settings.yml"
tasks:
- name: adjust composerified drupal docroot
sudo: true
lineinfile:
name=/etc/apache2/sites-available/{{ webserver_hostname }}.conf
line=" DocumentRoot /var/www/site/docroot/{{ webserver_custom_docroot }}"
regexp="\w*DocumentRoot /var/www/site/docroot"
state=present
notify:
- restart apache2
- name: adjust composerified drupal vhost directory
sudo: true
lineinfile:
name=/etc/apache2/sites-available/{{ webserver_hostname }}.conf
line=" <Directory /var/www/site/docroot/{{ webserver_custom_docroot }}>"
regexp="\w*<Directory /var/www/site/docroot.*"
state=present
notify:
- restart apache2
handlers:
- name: restart apache2
service: name=apache2 state=restarted
sudo: true
- name: restart httpd
service: name=httpd state=restarted
sudo: true
I've tried another way of doing this - if you want me to push my code, let me know.
I've added a variable for any additional folders that should be synced:
vagrant.yml: additional_synced_folders = []
So this could be set to the following for working with composer + moving the config directory outside of web root: additional_synced_folders: ['../config', '../vendor']
In the Vagrantfile, I've added the following for nfs when the docroot + vlad_aux folders are set up (currently at around line 290 against latest dev):
# Setup additional synced folders
vconfig['additional_synced_folders'].each do |dir_path|
dir_name = dir_path.split('/').last
config.vm.synced_folder dir_path, "/var/www/site/#{dir_name}", type: "nfs", nfs_udp: false, create: true, id: "vagrant-#{dir_name}"
end
And for rsync:
# Setup additional synced folders
vconfig['additional_synced_folders'].each do |dir_path|
dir_name = dir_path.split('/').last
config.vm.synced_folder dir_path, "/var/www/site/#{dir_name}", type: "rsync", create: true, id: "vagrant-#{dir_name}"
end
This will then put the folders at the same level as docroot:
$ pwd
/var/www/site
$ ls
config
docroot
logs
tests
vlad_aux
I had to use dir_name = dir_path.split('/').last
to get the directory name, otherwise if the variable was '../vendor', it would place it one level up. I also didn't add the code for Windows, as I don't have a windows setup to test it on.
I'm keen to help get this feature in, so we can use composer for managing Drupal as mlander says. Let me know how I can help!
Cheers
@gareth-fivemile Sounds reasonable to me. Could you do a PR against latest dev so that we can test/review this? Cheers!
In Drupal 8, I think you'll see more dependencies and scripts living outside of docroot, particularly when installed via composer(i.e. https://github.com/drupal-composer/drupal-project).
A directory may end up looking like: docroot -> ./web scripts vendor vlad vlad_aux web
I think minimum, having the 'vendor' directory would suffice, but perhaps allowing for an array of values? I'm not sure how much of a performance hit it would be to have additional synced directories?