Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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"
# (internal) name of Vagrant box
box_name = "jenkins-agent-ansible"
# public IP address to be assigned to the vagrant box
box_ip = ""
# host name to be assigned to the vagrant box
box_hostname = ""
# is the "special IP" to access host from within vagrant box
box_proxy = ""
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| = "centos/7"
machine.vm.hostname = box_hostname :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 = box_name
v.memory = 4096
v.cpus = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment