tmatilai / vagrant-proxyconf

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

Very verbose plugin #131

Closed giulioprovasi closed 9 years ago

giulioprovasi commented 9 years ago

When using the plugin, here what my vagrant up looks like :

==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Configuring proxy for Apt...
==> default: Configuring proxy environment variables...
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Mounting shared folders...
    default: /vagrant => C:/Workspace/vagrant
    default: /var/www/html => C:/Workspace/code
    default: /home/vagrant/downloads => C:/Users/xxx/Downloads
==> default: Running provisioner: file...
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-1fvx8sz.sh
==> default: Updating certificates  in /etc/ssl/certs...
==> default: 1 added, 0 removed; done.
==> default: Running hooks in /etc/ca-certificates/update.d....
==> default: done.
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-1h3tye5.sh
==> default: nginx stop/waiting
==> default: nginx start/running, process 4230
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 4245
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-1suw3xx.sh
==> default: nginx stop/waiting
==> default: nginx start/running, process 4352
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 4367
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-tr52gr.sh
==> default: Warning: Using a password on the command line interface can be insecure.
==> default: Warning: Using a password on the command line interface can be insecure.
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 4996
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Updating composer...
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Updating apt-get repos...
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-gm9b74.sh
==> default: Installing ntp
==> default: Configuring timezone
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-f9jsgl.sh
==> default: Installing Oracle support
==> default: Offline install from binaries
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 13845
==> default: nginx stop/waiting
==> default: nginx start/running, process 13859
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-yyxb90.sh
==> default: Installing MSSQL support
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 15532
==> default: nginx stop/waiting
==> default: nginx start/running, process 15546
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-1i1405r.sh
==> default: Creating MSSQL connector <XXX>
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-e2j9bh.sh
==> default: Creating MSSQL connector <YYY>
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...
    default: Running: C:/Workspace/devel/cygwin64/tmp/vagrant-shell20150909-9452-kx9qso.sh
==> default: Disabling xdebug
==> default: nginx stop/waiting
==> default: nginx start/running, process 15873
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 15888
==> default: Installing Laravel/installer=~1.1
==> default: nginx stop/waiting
==> default: nginx start/running, process 16537
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 16552
==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...

How comes that each time that a provisioner is ran, the proxy updates is invoked ?

==> default: Configuring proxy for npm...
==> default: Configuring proxy for PEAR...
==> default: Running provisioner: shell...

Here's my conf:

proxies:
   apt: http://testproxy:80
   corporate:
       user: user
       passwd: pwd
       # do not speficy protocol
       url: 1.1.1.1:80
       no_proxy: '*.lab,localhost,127.0.0.*,10.*,192.168.*'

And my vagrant file :


    if settings.has_key?("proxies")

      # corporate proxy
      if settings["proxies"].has_key?("corporate")
        corporate_proxy = settings["proxies"]["corporate"]
        user = corporate_proxy["user"]
        passwd = corporate_proxy["passwd"]
        url = corporate_proxy["url"]
        config.proxy.http = "http://#{user}:#{passwd}@#{url}/"
        config.proxy.https = "http://#{user}:#{passwd}@#{url}/"
        config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
      end

      # apt anonymous proxy
      config.apt_proxy.http = settings["proxies"]["apt"] || "DIRECT"
      config.apt_proxy.https = settings["proxies"]["apt"] || "DIRECT"
    end
tmatilai commented 9 years ago

Uh, you have a lot of provisioners. =)

The reason to trigger the proxy configurations after provisioner runs is that it is a common case to install npm, PEAR, git, etc. using a provisioner, while the base box doesn't have them. So you can first install for example npm with one provisioner, and then use it with proxies already configured in another one, without the need to run vagrant provision multiple times.

I guess we could ensure we only run the configuration once, but this is the first time anyone ever complains about this. :) If you feel this would be needed, I'm happy to take a look at a PR.

giulioprovasi commented 9 years ago

I understand and it's not a problem indeed :), I was just curious about why it ran so frequently. I have a lot of provisioners as I tried to start a minimalist machine and add stuffs only by provisioning them.

tmatilai commented 9 years ago

I think a more common approach is to have one (or few anyway) provisioner run that does more things. I prefer to use a configuration management tool (Chef, Puppet, Ansible, ...) if a shell script is not trivial.

giulioprovasi commented 9 years ago

I get your point, I am just starting using all those provisioning tools, so for this time the use of vagrant provisioners was far more easy, but I'll get into Chef/Puppet as soon as I can