2014年6月14日土曜日

プロキシ環境下でChef Soloをインストールする

環境
  • Ubuntu Server 12.04 LTS x64

apt-get用にプロキシ設定を追加
$ sudo vi /etc/apt/apt.conf
$ cat /etc/apt/apt.conf
(関係箇所のみ抜粋)
Acquire::http::Proxy "http://proxy.example.com:8080";
Acquire::https::Proxy "http://proxy.example.com:8080";
Acquire::ftp::Proxy "http://proxy.example.com:8080";

vim、curlのインストール
$ sudo apt-get update -y
$ sudo apt-get install -y vim curl

プロキシ用の環境変数を追加
$ vim ~/.bashrc
$ cat ~/.bashrc
(関係箇所のみ抜粋)
export http_proxy="http://proxy.example.com:8080"
export https_proxy="http://proxy.example.com:8080"
export ftp_proxy="http://proxy.example.com:8080"

$ source ~/.bashrc


wget用にプロキシ設定を追加(後で実行するオムニバスインストーラスクリプト内でwgetが実行されるため)
$ sudo vim /etc/wgetrc

/etc/wgetrc(関係箇所のみ抜粋)
# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
https_proxy = http://proxy.example.com:8080
http_proxy = http://proxy.example.com:8080
ftp_proxy = http://proxy.example.com:8080

# If you do not want to use proxy at all, set this to off.
use_proxy = on


オムニバスインストーラを使ってChefをインストール
$ curl -L https://www.opscode.com/chef/install.sh | sudo bash

Chef Soloのバージョン確認
$ chef-solo -v


補足

wgetについて個別にプロキシ設定しない場合は、sudoコマンドにEオプションをつけることにより、ログインアカウントの環境変数を引き継いでインストールスクリプトを実行する。

$ curl -L https://www.opscode.com/chef/install.sh | sudo -E bash


[参考URL]
The little, that can make a difference...: Unable to add ppa behind proxy