tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

Proxy not working with Chef-Solo when using recipe_url #76

Open tibraga opened 10 years ago

tibraga commented 10 years ago

Hello,

When I use the Chef-Solo with recipe_url, I receive the error bellow:

/usr/lib/ruby/1.9.1/open-uri.rb:346:in `open_http': 407 Proxy Authentication Required (OpenURI::HTTPError)
    from /usr/lib/ruby/1.9.1/open-uri.rb:775:in `buffer_open'
    from /usr/lib/ruby/1.9.1/open-uri.rb:203:in `block in open_loop'
    from /usr/lib/ruby/1.9.1/open-uri.rb:201:in `catch'
    from /usr/lib/ruby/1.9.1/open-uri.rb:201:in `open_loop'
    from /usr/lib/ruby/1.9.1/open-uri.rb:146:in `open_uri'
    from /usr/lib/ruby/1.9.1/open-uri.rb:677:in `open'
    from /usr/lib/ruby/1.9.1/open-uri.rb:33:in `open'
    from /var/lib/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:196:in `block in reconfigure'
    from /var/lib/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:195:in `open'
    from /var/lib/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:195:in `reconfigure'
    from /var/lib/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:65:in `run'
    from /var/lib/gems/1.9.1/gems/chef-11.12.8/bin/chef-solo:25:in `<top (required)>'
    from /usr/local/bin/chef-solo:23:in `load'
    from /usr/local/bin/chef-solo:23:in `<main>'
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

The configuration's plugin vagrant-proxyconf is correct, because before the chef-solo, I use the apt-get that works fine.

Thanks.

otahi commented 10 years ago

@tibraga Hello, Sorry, I don't understand what happened correctly.

The error open_http': 407 Proxy Authentication Required means chef-solo uses http_proxy, but userinfo is missing to use the auth-proxy which http_proxy specified.

How did you run chef-solo? Can you show the Vagrantfile which you used. I think chef-solo provisioner works auth-proxy.

tibraga commented 10 years ago

@otahi Hello,

Follow below my Vagrantfile(changed to code blocks by @otahi):

VAGRANTFILE_API_VERSION = "2"

$build_script = <<SCRIPT
curl -L https://www.opscode.com/chef/install.sh | bash
echo "Client Chef installed"
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "vagrant-ubuntu-14.04-mule"
  config.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box"
  config.vm.network "private_network", ip: "192.168.50.4"
  config.vm.synced_folder "target/apps/", "/opt/mule/apps/", create: true

  if Vagrant.has_plugin?("vagrant-proxyconf")
      config.proxy.http     = "http://huti:huti1234@proxy.corp.corporate.com.br:3128/"
      config.proxy.https    = "http://huti:huti1234@proxy.corp.corporate.com.br:3128/"
      config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
  end

  config.vm.provision :shell, inline: $build_script

   config.vm.provision "chef_solo" do |chef|
        chef.recipe_url = "http://xxxx-xx.s3.amazonaws.com/chef-solo.tar.gz"
        chef.roles_path = "chef-solo/roles"
        chef.add_role("mule-api-manager")
   end

  config.vm.provider :virtualbox do |vb|
    vb.name = "Mule Manager B2B VM"
    vb.customize ["modifyvm", :id, "--memory", "2048"]
    vb.customize ["modifyvm", :id, "--cpus", "4"]
    vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
    vb.customize ["modifyvm", :id, "--nestedpaging", "on"]
  end
end

Look that before provision chef-solo, the virtual machine executes the command curl -L https://www.opscode.com/chef/install.sh | bash and that works because the plugin "vagrant-proxyconf" is configured correctly, but when executes the provision "chef-solo", occurs the error 407 Proxy Authentication Required. If I to execute wget http://xxxx-xx.s3.amazonaws.com/chef-solo.tar.gz in the virtual machine, it works.

tmatilai commented 10 years ago

@tibraga sorry for the delay in responding. Looks like there is some issue when setting the username/password for the Chef Solo provisioner. I'll try to reproduce this later when I get a chance.