Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #995 from oxyc/env-configs
Browse files Browse the repository at this point in the history
Issue #455: Allow for environment specific config files
  • Loading branch information
geerlingguy authored Nov 16, 2016
2 parents 96e0bc1 + 24450a9 commit 29658e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ guest_project_dir = '/vagrant'
guest_drupalvm_dir = ENV['DRUPALVM_DIR'] ? "/vagrant/#{ENV['DRUPALVM_DIR']}" : guest_project_dir
guest_config_dir = ENV['DRUPALVM_CONFIG_DIR'] ? "/vagrant/#{ENV['DRUPALVM_CONFIG_DIR']}" : guest_project_dir

drupalvm_env = ENV['DRUPALVM_ENV'] || 'vagrant'

# Cross-platform way of finding an executable in the $PATH.
def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
Expand All @@ -38,7 +40,7 @@ require 'yaml'
# Load default VM configurations.
vconfig = YAML.load_file("#{host_drupalvm_dir}/default.config.yml")
# Use optional config.yml and local.config.yml for configuration overrides.
['config.yml', 'local.config.yml'].each do |config_file|
['config.yml', 'local.config.yml', "#{drupalvm_env}.config.yml"].each do |config_file|
if File.exist?("#{host_config_dir}/#{config_file}")
vconfig.merge!(YAML.load_file("#{host_config_dir}/#{config_file}"))
end
Expand Down Expand Up @@ -124,14 +126,16 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision 'ansible' do |ansible|
ansible.playbook = "#{host_drupalvm_dir}/provisioning/playbook.yml"
ansible.extra_vars = {
config_dir: host_config_dir
config_dir: host_config_dir,
drupalvm_env: drupalvm_env
}
end
else
config.vm.provision 'ansible_local' do |ansible|
ansible.playbook = "#{guest_drupalvm_dir}/provisioning/playbook.yml"
ansible.extra_vars = {
config_dir: guest_config_dir
config_dir: guest_config_dir,
drupalvm_env: drupalvm_env
}
end
end
Expand Down
1 change: 1 addition & 0 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
with_fileglob:
- "{{ config_dir }}/config.yml"
- "{{ config_dir }}/local.config.yml"
- "{{ config_dir }}/{{ lookup('env', 'DRUPALVM_ENV')|default(drupalvm_env, true)|default(ansible_env.DRUPALVM_ENV)|default(omit) }}.config.yml"

- include: tasks/init-debian.yml
when: ansible_os_family == 'Debian'
Expand Down

0 comments on commit 29658e5

Please sign in to comment.