Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

Commit

Permalink
Load default config directly from project directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
thom8 committed Jun 14, 2017
1 parent 9b03fd5 commit 61eda22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
35 changes: 8 additions & 27 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,26 @@ beet_root = ENV['BEET_ROOT_DIR'] || "#{__dir__}"
config_dir = ENV['BEET_CONFIG_DIR'] || "#{beet_root}/.beetbox"
project_config = "#{config_dir}/config.yml"
local_config = "#{config_dir}/local.config.yml"
composer_json = "#{beet_root}/composer.json"
composer_conf = JSON.parse(File.read("#{beet_root}/composer.json"))
vendor_dir = composer_conf['config']['vendor-dir'] || 'vendor'
default_config = "#{vendor_dir}/beet/box/provisioning/ansible/config/default.config.yml"
default_config = "provisioning/ansible/config/default.config.yml" if !File.exist?(default_config)

# Default vagrant config.
vconfig = {
'vagrant_box' => 'beet/box',
'vagrant_box_version' => '~> 0.6.0',
'vagrant_ip' => '0.0.0.0',
'vagrant_memory' => 1024,
'vagrant_cpus' => 1,
'beet_project' => 'drupal',
'beet_profile' => 'beetbox',
'beet_provision_playbook' => 'provision',
'beet_provision_tags' => 'all',
'beet_home' => '/beetbox',
'beet_base' => '/var/beetbox',
'beet_domain' => beet_root.split('/').last.gsub(/[\._]/, '-') + ".local",
'beet_aliases' => [],
'beet_provision' => true,
'drush_create_alias' => true
}
vconfig = YAML::load_file(default_config)
vconfig['beet_domain'] = beet_root.split('/').last.gsub(/[\._]/, '-') + ".local"

# Create config directory.
FileUtils.mkdir_p config_dir

# Create config.yml from composer config.
if File.exist?(composer_json)
composer_conf = JSON.parse(File.read(composer_json))
cconfig = composer_conf['extra']['beetbox'] rescue nil
File.open(project_config, "w") { |f| f.write(cconfig.to_yaml) } if cconfig.is_a?(Hash)
end
cconfig = composer_conf['extra']['beetbox'] rescue nil
File.open(project_config, "w") { |f| f.write(cconfig.to_yaml) } if cconfig.is_a?(Hash)

# Create default config file.
default_config = "---\nbeet_domain: #{vconfig['beet_domain']}\n"
File.open(project_config, "w") { |f| f.write(default_config) } if !File.exist?(project_config)

# Create .gitignore file.
git_ignore = "host.config.yml\nlocal.config.yml\nVagrantfile\nVagrantfile.local\n"
File.open("#{config_dir}/.gitignore", "w") { |f| f.write(git_ignore) } if !File.exist?("#{config_dir}/.gitignore")

# Copy config from host.
host_config = "#{Dir.home}/.beetbox/config.yml"
if File.exist?(host_config)
Expand Down
14 changes: 12 additions & 2 deletions provisioning/ansible/config/default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
# Copy any of these settings to the custom config file to override.
#

# Vagrant config.
vagrant_box: beet/box
vagrant_box_version: "~> 0.5.0"
vagrant_ip: "0.0.0.0"
vagrant_memory: "1024"
vagrant_cpus: 1

# Beetbox config.
beet_profile: beetbox
beet_repo: "{{ lookup('env','BEET_REPO') | default('https://github.com/beetboxvm/beetbox.git',true) }}"
beet_version: "{{ lookup('env','BEET_VERSION') | default('master',true) }}"
beet_home: "{{ lookup('env','BEET_HOME') | default('/beetbox',true) }}"
beet_home: "/beetbox"
beet_role_dir: "{{ beet_home }}/provisioning/ansible/roles"
beet_project: drupal
beet_debug: no
Expand All @@ -18,7 +26,7 @@ beet_aliases: []
beet_env_name: BB_ENVIRONMENT
beet_env: vagrant
beet_user: "{{ lookup('env','BEET_USER') | default('vagrant',true) }}"
beet_base: "{{ lookup('env','BEET_BASE') | default('/var/beetbox',true) }}"
beet_base: "/var/beetbox"
beet_root: "{{ beet_base }}"
beet_web: "{{ beet_root }}"
beet_ssh_home: "{{ beet_root }}"
Expand All @@ -30,6 +38,8 @@ beet_mysql_database: "beetbox"
beet_custom_pre_tasks: "{{ beet_base }}/.beetbox/tasks/pre"
beet_custom_post_tasks: "{{ beet_base }}/.beetbox/tasks/post"
beet_root_create: yes
beet_provision_playbook: provision
beet_provision_tags: all
beet_provision: yes

# Symlinks.
Expand Down

0 comments on commit 61eda22

Please sign in to comment.