Chefを使ってみる No1(Install)
Chefは「Infrastructure as Code」、「べき等性」という概念があり
・サーバーの構成をコード管理する。
・サーバーを何回構築しても同じものができる。
という特徴がある。
Chefの構成は以下のようになっているらしい。
インストール方法はここに記載されている。
今回はスタンドアロンで勉強していく。
スタンドアロンの場合はchef-soloを使うようだ。
Chefのクライアントもサーバーもココに記載されているスクリプトをコピペする。
クライアント側
chef client
chef serverにアクセスするもの。
$ curl -L https://www.opscode.com/chef/install.sh | sudo bash
......
Thank you for installing Chef!
バージョン確認
$ chef-client -v
Chef: 11.10.4
サーバー側
$ wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.11-1.ubuntu.12.04_amd64.deb
$ sudo dpkg -i chef-server_11.0.11-1.ubuntu.12.04_amd64.deb
$ sudo chef-server-ctl reconfigure
設定する。ここが参考になる。
①サーバーへアクセスする。
https://localhost:443
②ログイン画面では右端に初期adminとパスワードが記載されているので
それを使ってログインする。
③パスワードを変更する。
④初回しか表示されないprivate key, public keyをコピーしておく。
⑤/opt/chef-server/admin.pemへprivate keyを記載
⑥/opt/chef-server/chef-validator.pemへpublic keyを記載
<リポジトリ作成>
ココが参考になる。
$ cd ~/
$ git clone git://github.com/opscode/chef-repo.git
Knife設定
ここで先ほどのadmin.pem, chef-validator.pemを使う。
$ knife configure -i
Where should I put the config file? [/home/keisuke/.chef/knife.rb]
Please enter the chef server URL: [https://gabriel:443]
Please enter a name for the new user: [keisuke]
Please enter the existing admin name: [admin]
Please enter the location of the existing admin's private key: [/etc/chef-server/admin.pem] /opt/chef-server/admin.pem
Please enter the validation clientname: [chef-validator]
Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem] /opt/chef-server/chef-validator.pem
Please enter the path to a chef repository (or leave blank):
Creating initial API user...
Please enter a password for the new user:
Created user[keisuke]
Configuration file written to /home/keisuke/.chef/knife.rb
Opscode Community
サーバー構築自動化ツール Chef 最新版のインストール方法
ChefDocument chef-solo
knife-soloによるChefの実行