Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@michaellihs
Created June 21, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellihs/f4bc4f297d696f7186448f7198f24b06 to your computer and use it in GitHub Desktop.
Save michaellihs/f4bc4f297d696f7186448f7198f24b06 to your computer and use it in GitHub Desktop.
Vagrantfile with Proxy config
# this configuration requires the vagrant-proxyconf plugin to be installed
# vagrant plugin install vagrant-proxyconf
if ENV["http_proxy"].nil?
abort "\e[31mERROR: you have to set the $http_proxy environment variable\e[0m"
end
# (internal) name of Vagrant box
box_name = "jenkins-agent-ansible"
# public IP address to be assigned to the vagrant box
box_ip = "192.168.33.11"
# host name to be assigned to the vagrant box
box_hostname = "jenkins-agent.dev.localhost"
# 10.0.2.2 is the "special IP" to access host from within vagrant box
box_proxy = "http://10.0.2.2:3128"
puts "\e[32m[info] Using Vagrant system proxy: #{ENV["http_proxy"]} \e[0m"
puts "\e[32m[info] Using Vagrant box proxy: #{box_proxy} \e[0m"
Vagrant.configure("2") do |config|
# these proxy settings are used by Vagrant
# e.g. to download boxes or meta data
config.proxy.http = ENV["http_proxy"]
config.proxy.https = ENV["http_proxy"]
config.proxy.no_proxy = ENV["no_proxy"]
config.vm.define box_name do |machine|
machine.vm.box = "centos/7"
machine.vm.hostname = box_hostname
machine.vm.network :private_network, ip: box_ip
machine.vm.provider "virtualbox" do |v, override|
# these proxy settings are used from within the box
# e.g. yum config, curl, ...
override.proxy.http = box_proxy
override.proxy.https = box_proxy
v.name = box_name
v.memory = 4096
v.cpus = 2
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment