I’m working on simplifying the process of creating a new development sites in my bedrock-ansible Vagrant VM.
I run a single VM for all of my development sites. Previously I would add each new site to group_vars/development, then set up the host alias and mount the synced folder in my Vagrantfile.
I got around modifying the Vagrantfile for each site by simply reading in group_vars/development and using that information in the Vagrantifle:
group_vars = YAML.load(File.read('group_vars/development'))
group_vars['wordpress_sites'].each do |site|
site_name = site['site_name']
config.hostsupdater.aliases.push(site_name)
config.vm.synced_folder "../#{site_name}", "/vagrant-nfs-#{site_name}", type: 'nfs'
config.bindfs.bind_folder "/vagrant-nfs-#{site_name}", "/srv/www/#{site_name}/current", u: 'vagrant', g: 'www-data'
end
Nothing too fancy, but it let me delete 20-odd repetitive lines in my Vagrantfile.