LoginSignup
77
80

More than 5 years have passed since last update.

VagrantのかんたんProxy設定

Last updated at Posted at 2013-10-03

VagrantのかんたんProxy設定

この記事は

Vagrantで作成するゲストOS側にProxy設定をする手順です。
vagrant-omnibusでChef-solo入れるにもProxy設定されてなくて入らなくて調べました。

プラグインを使う

vagrant-proxyconfというプラグインが公開されています。これ使えば解決です。

インストール

普通に入れてください。

>vagrant plugin install vagrant-proxyconf
Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...
Installed the plugin 'vagrant-proxyconf (0.5.3)'!

設定ファイル

プロキシ情報を書きます。

Vagrantfile
Vagrant.configure("2") do |config|
  config.proxy.http     = "http://192.168.0.2:3128/"
  config.proxy.https    = "http://192.168.0.2:3128/"
  config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
  # ... other stuff
end

実行

vagrant upすると下記のメッセージでて設定できてます。

>vagrant up
(snip)
[default] Configuring proxy for Apt...
[default] Configuring proxy for Chef provisioners...
[default] Configuring proxy environment variables...
(snip)

設定内容

今のところaptとchefと環境変数のプロキシ設定してくれるみたいです。

たぶんこの辺にクラス追加すれば設定対象増やせそうです。

他に各プログラム固有のProxy設定とかサポートしたい場合はforkして自分で実装してpull request出したら世界中のプロキシ野郎が喜ぶしれませんね。

うまくいかない時

ソースを見るとオプションで連携できる他のプラグインが3つ定義されているのですが、どうもこれを入れないとうまくProxy設定してくれない場合もあるようです。うまくいかないときは下記をインストールすると動くかもしれません。

>vagrant plugin install vagrant-aws
>vagrant plugin install vagrant-omnibus
>vagrant plugin install vagrant-vbguest

終わりに

よかったよかった。

77
80
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
77
80