2. Chef Clientインストール
knifeコマンドなどを使用するためには、Chef Clientのインストールが必要です。
Chef Serverのパッケージをダウンロードした時と同様に、Opescode社のサイトよりClientのインストールパッケージがダウンロードできます。
2013年10月現在、次のOSに対応しています。
- Debian 6, 7(i386, x86_64)
- RHEL 5, 6(i686, x86_64)
- Free BSD 9(adm64, i386)
- OS X 10.6, 10.7(x86_64)
- SUSE Enterprise Linux 11.2(i386, x86_64)
- Solaris 5.9(sparc)
- Solaris 5.10, 5.11(i386, sparc)
- openSUSE 12.1(i686, x86_64)
- Ubuntu 10.04, 10.10, 11.04, 11.10, 12.04, 12.10, 13.04(i386, x86_64)
Windowsは、次に対応しており、msi形式のインストーラが提供されています。
- Windows 2003r2(i686, x86_64)
- Windows 2008r2(x86_64)
- Windows 2008(i686, x86_64)
- Windows 2012(x86_64)
パッケージをホストにダウンロードしインストールすることも可能ですが、次のコマンドを実行すると、最新版パッケージのダウンロード・インストールが行えます。
chef-ws@workstation:~$ curl -L https://www.opscode.com/chef/install.sh | sudo bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6790 100 6790 0 0 4325 0 0:00:01 0:00:01 --:--:-- 6139
Downloading Chef for ubuntu...
Installing Chef
:
:
:
Thank you for installing Chef!
curlがインストールされていない場合は、別途インストールを実施してください。
「Thank you for installing Chef!」とメッセージが表示されたら、インストールは成功です。次のコマンドを実行すると、Chef Clientのバージョンが確認できます。
chef-ws@workstation:~$ chef-client -v Chef: 11.6.2
また、このインストーラによって/opt/chef以下にすべての必要なファイルがインストールされます。
chef-ws@workstation:~$ dpkg -L chef | cut -d/ -f1-4 | uniq /. /opt /opt/chef /opt/chef/version-manifest.txt /opt/chef/embedded /opt/chef/bin /opt/chef/embedded
3. Chefリポジトリの作成
Chef Clientの関連ファイルをバージョン管理するためには、Workstation上にchef-repoリポジトリを作成します。
リポジトリのテンプレートはgithubから入手できます。
chef-ws@workstation:~$ git clone git://github.com/opscode/chef-repo.git Cloning into 'chef-repo'... remote: Counting objects: 223, done. remote: Compressing objects: 100% (139/139), done. remote: Total 223 (delta 80), reused 177 (delta 49) Receiving objects: 100% (223/223), 38.14 KiB, done. Resolving deltas: 100% (80/80), done.
gitがインストールされていない場合は、別途インストールを実施してください。
今回は作成されたchef-repoディレクトリに.chefディレクトリを作成します。
chef-ws@workstation:~$ mkdir ~/chef-repo/.chef chef-ws@workstation:~$ ls -la ~/chef-repo/ total 68 drwxr-xr-x 10 chef-ws chef-ws 4096 Oct 16 16:33 . drwxr-xr-x 5 chef-ws chef-ws 4096 Oct 16 19:40 .. drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 16:26 certificates drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 17:08 .chef -rw-rw-r-- 1 chef-ws chef-ws 156 Oct 16 16:26 chefignore drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 16:26 config drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 16:26 cookbooks drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 16:26 data_bags drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 16:26 environments drwxrwxr-x 8 chef-ws chef-ws 4096 Oct 16 16:26 .git -rw-rw-r-- 1 chef-ws chef-ws 106 Oct 16 16:26 .gitignore -rw-rw-r-- 1 chef-ws chef-ws 10850 Oct 16 16:26 LICENSE -rw-rw-r-- 1 chef-ws chef-ws 2169 Oct 16 16:26 Rakefile -rw-rw-r-- 1 chef-ws chef-ws 3510 Oct 16 16:26 README.md drwxrwxr-x 2 chef-ws chef-ws 4096 Oct 16 16:26 roles
次に、管理ユーザやクライアントの追加等に用いる鍵ファイルadmin.pemとchef-validator.pemを、Chef ServerからWorkstationの~/chef-repo/.chefにコピーします。
admin.pemとchef-validator.pemは、Chef Serverの/etc/chef-serverディレクトリにあります。
Chef Serverへログインし、/etc/chef-server/admin.pemと/etc/chef-server/chef-validator.pemをscpコマンドでClientへコピーします。
chef-sv@chef11:~$ sudo scp /etc/chef-server/admin.pem /etc/chef-server/chef-validator.pem chef-ws@workstation:~/chef-repo/.chef
chef-ws@workstation:~/chef-repo/.chef$ ls -la *.pem -rw------- 1 chef-ws chef-ws 1675 Oct 16 16:52 admin.pem -rw------- 1 chef-ws chef-ws 1679 Oct 16 16:53 chef-validator.pem

