Created
April 29, 2014 15:24
-
-
Save jmolivas/11403587 to your computer and use it in GitHub Desktop.
Adding customizable configuration to Vagrantfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "yaml" | |
parameter_file = "./parameters.yml" | |
parameters = Array.new(0) | |
if File.exists?(parameter_file) | |
parameters = YAML::load_file(parameter_file) | |
end | |
# Apply configuration values if available | |
config.vm.network "private_network", ip: (parameters.include?'network_ip') ? parameters['network_ip'] : "192.168.9.10" | |
config.vm.synced_folder "./www", "/var/www", id: "webroot", type: (parameters.include?'synced_folder_type') ? parameters['synced_folder_type'] : "nfs" | |
virtualbox.customize ["modifyvm", :id, "--memory", (parameters.include?'memory') ? parameters['memory'] : "512"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
En un ejercicio extra, puedes reducir esto así:
De nuevo, la explicación:
params = { }
antes de hacer algo con él.||
, traduciéndose como params es lo que resulte de abrir via YAML este archivo, o un Hash vacío