Skip to content

Instantly share code, notes, and snippets.

@yusukegoto
Created August 12, 2014 02:43
Show Gist options
  • Save yusukegoto/0af0bf47101fe6c1fabf to your computer and use it in GitHub Desktop.
Save yusukegoto/0af0bf47101fe6c1fabf to your computer and use it in GitHub Desktop.
concern about usage with vagrant-proxyconf and kitchen-vagrant.
Vagrant.configure("2") do |c|
c.vm.box = "<%= config[:box] %>"
c.vm.box_url = "<%= config[:box_url] %>"
if Vagrant.has_plugin?("vagrant-proxyconf")
c.proxy.http = "<%= config[:http_proxy] %>"
c.proxy.https = "<%= config[:http_proxy] %>"
c.proxy.no_proxy = "<%= config[:no_proxy] %>"
end
<% if config[:vm_hostname] %>
c.vm.hostname = "<%= config[:vm_hostname] %>"
<% end %>
<% if config[:guest] %>
c.vm.guest = <%= config[:guest] %>
<% end %>
<% if config[:username] %>
c.ssh.username = "<%= config[:username] %>"
<% end %>
<% if config[:ssh_key] %>
c.ssh.private_key_path = "<%= config[:ssh_key] %>"
<% end %>
<% Array(config[:network]).each do |opts| %>
c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>)
<% end %>
c.vm.synced_folder ".", "/vagrant", disabled: true
<% config[:synced_folders].each do |source, destination, options| %>
c.vm.synced_folder "<%= source %>", "<%= destination %>", <%= options %>
<% end %>
c.vm.provider :<%= config[:provider] %> do |p|
<% config[:customize].each do |key, value| %>
<% case config[:provider]
when "virtualbox" %>
p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
<% when "rackspace", "softlayer" %>
p.<%= key %> = "<%= value%>"
<% when /^vmware_/ %>
<% if key == :memory %>
<% unless config[:customize].include?(:memsize) %>
p.vmx["memsize"] = "<%= value %>"
<% end %>
<% else %>
p.vmx["<%= key %>"] = "<%= value %>"
<% end %>
<% end %>
<% end %>
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment