knife-soloを使ってChef環境を構築
前回の続き。
今回はknife-soloでゲストOSにchef環境をつくる。
chef-soloとknife-soloで手軽に環境構築をする - Bouldering & Com.を見ながら。
すべてホストOS(Mac側)での作業です。
- chef, knife-soloのインストール
$ sudo gem install chef $ sudo gem install knife-solo
- knifeの設定ファイルを作る
$ knife configure Password: WARNING: No knife configuration file found Where should I put the config file? [/path/to/.chef/knife.rb] Please enter the chef server URL: [https://machine-name:443] Please enter an existing username or clientname for the API: [username] Please enter the validation clientname: [chef-validator] Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem] Please enter the path to a chef repository (or leave blank): ***** You must place your client key in: /path/to/.chef/username.pem Before running commands with Knife! ***** You must place your validation key in: /etc/chef-server/chef-validator.pem Before generating instance data with Knife! ***** Configuration file written to /path/to/.chef/knife.rb
# Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.network :private_network, ip: "192.168.33.10"
最後のコメントアウトを外す
-
- ~/.ssh/configの設定
$ emacs ~/.ssh/config Host 192.168.33.10 User vagrant Port 22 IdentityFile "~/.vagrant.d/insecure_private_key"
- knife-soloでゲストOSにchef環境をインストール
$ knife solo prepare vagrant@192.168.33.10 Bootstrapping Chef... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 101 6790 101 6790 0 0 913 0 0:00:07 0:00:07 --:--:-- 13942 Downloading Chef 11.6.0 for el... Installing Chef 11.6.0 warning: /tmp/tmp.pJDflK3i/chef-11.6.0.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY Preparing... ########################################### [100%] 1:chef ########################################### [100%] Thank you for installing Chef! Generating node config 'nodes/192.168.33.10.json'...
ssh設定したけどどうにもconnection refuseされて困ってたけどvagrant halt, vagrant upで再起動したらいけた。
てかそもそもknife, knife-soloとは。
・knife:chefに同梱されてる管理ツール。
・knife-solo:knifeを使うためのプラグイン。chefのレシピをいちいちgithubとかから経由しなくてもローカルで作ったレシピをrsyncしてリモートでchef-soloを実行してくれるらしい。
開発メモ#5 : Amazon Linux で knife-solo を使って chef-solo 実行 - naoyaのはてなダイアリー