wordpress なソレを評価してみる
以下から取得できるヤツ。
どうやらでびあん系に依存しているようなので precise32 な box も取得。
$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
とりあえず、recipes/default.rb から確認してみます。
include_recipe
以下な記述が先頭にあります。
include_recipe "apache2" include_recipe "mysql::server" include_recipe "php" include_recipe "php::module_mysql" include_recipe "apache2::mod_php5"
これは cookbooks の中にこれらが、ということなのかな。以下な cookbook が必要なのかどうなのか。
探してみたところ、以下から取得すれば良いのかな?
$ git clone git://github.com/opscode-cookbooks/apache2.git $ git clone git://github.com/opscode-cookbooks/php.git $ git clone git://github.com/opscode-cookbooks/mysql.git
vagrant box add 終了
以下な Vagrantfile をでっち上げて vagrant up 実行。
Vagrant.configure("2") do |config| config.vm.box = "precise32" config.vm.network :private_network, ip: "192.168.33.10" config.vm.provider :virtualbox do |vb| # Don't boot with headless mode vb.gui = true # Use VBoxManage to customize the VM. For example to change memory: vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] #vb.customize ["modifyvm", :id, "--memory", "1024"] end end
chef で云々
手順は以下なのかな。
- knife solo init chef-repo
- 違う、knife kitchen chef-repo か
- git で云々
- cd chef-repo
- git init && git add . && git commit -m 'initial commit'
- knife solo prepare 192.168.33.10
- git で云々
- git add nodes/192.168.33.10.json
- git commit -m 'add node json file'
- クックブック作成 & レシピ編集
- cookbooks 配下に git clone
で、
- knife solo cook 192.168.33.10 実行
になるのですが、nodes/192.168.33.10.json にどんな記述を盛り込むべきなのか。
{ "run_list":[ "wordpress" ] }
で良いのかな。ちょいヤッてみます。
$ knife solo init chef-repo Creating kitchen... Creating knife.rb in kitchen... ERROR: knife encountered an unexpected error This may be a bug in the 'solo init' knife command or plugin Please collect the output of this command with the `-VV` option before filing a bug report. Exception: NameError: uninitialized constant KnifeSolo::Pathname
あ、knife kitchen chef-repo だった。
$ knife kitchen chef-repo WARNING: `knife kitchen` is deprecated! Please use: knife solo init DIRECTORY Creating kitchen... Creating knife.rb in kitchen... Creating cupboards...
deprecated って言いつつ使え、って方が動かないて何スか。で、git で云々しといて
$ cd chef-repo $ git init && git add . && git commit -m 'initial commit'
以下を実行。
$ knife solo prepare 192.18.33.10 Bootstrapping Chef... --2013-05-02 08:03:01-- https://www.opscode.com/chef/install.sh Resolving www.opscode.com (www.opscode.com)... 184.106.28.83 Connecting to www.opscode.com (www.opscode.com)|184.106.28.83|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6510 (6.4K) [application/x-sh] Saving to: `install.sh' 100%[======================================>] 6,510 --.-K/s in 0s 2013-05-02 08:03:02 (592 MB/s) - `install.sh' saved [6510/6510] Downloading Chef 11.4.4 for ubuntu... Installing Chef 11.4.4 Selecting previously unselected package chef. (Reading database ... 29361 files and directories currently installed.) Unpacking chef (from .../chef_11.4.4_i386.deb) ... Setting up chef (11.4.4-1.ubuntu.11.04) ... Thank you for installing Chef! Generating node config 'nodes/192.168.33.10.json'...
で、追加されたファイルを以下な状態に。
{"run_list":["wordpress"]}
一応 git で云々しとく。
$ git add nodes/192.168.33.10.json $ git commit -m 'add node json file'
で、cookbooks 配下で以下。
$ cd cookbooks $ git clone git://github.com/cookbooks/wordpress.git $ git clone git://github.com/opscode-cookbooks/apache2.git $ git clone git://github.com/opscode-cookbooks/php.git $ git clone git://github.com/opscode-cookbooks/mysql.git $ cd ..
で、実行してみます。
$ knife solo cook 192.168.33.10 Running Chef on 192.168.33.10... Checking Chef version... Uploading the kitchen... Generating solo config... Running Chef... Starting Chef Client, version 11.4.4 Compiling Cookbooks... Converging 0 resources Chef Client finished, 0 resources updated
ありゃ? と思ったら nodes/192.168.33.10.json を更新してなかったよorz
上書きしてリトライ。
$ knife solo cook 192.168.33.10 Running Chef on 192.168.33.10... Checking Chef version... Uploading the kitchen... Generating solo config... Running Chef... Starting Chef Client, version 11.4.4 Compiling Cookbooks... [2013-05-02T08:11:19+00:00] ERROR: Running exception handlers [2013-05-02T08:11:19+00:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated [2013-05-02T08:11:19+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out [2013-05-02T08:11:19+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook build-essential not found. If you're loading build-essential from another cookbook, make sure you configure the dependency in your metadata ERROR: RuntimeError: chef-solo failed. See output above.
あら、build-essential も必要なのか。ちょっと cookbooks 配下は確認した方が良いですね。
- build-essential
- apt
- logrotate
- xml
- は叱られたら入れる
ということで上三つをナニ。
$ git clone git://github.com/opscode-cookbooks/build-essential.git $ git clone git://github.com/opscode-cookbooks/apt.git $ git clone git://github.com/opscode-cookbooks/logrotate.git
で、リトライするも openssl が、と叱られた。
[2013-05-02T08:16:18+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook openssl not found. If you're loading openssl from another cookbook, make sure you configure the dependency in your metadata
入れます。
$ git clone git://github.com/opscode-cookbooks/openssl.git
で、リトライ。xml が無いとのこと。
$ git clone git://github.com/opscode-cookbooks/xml.git
このあたり、上手に解決できんかな。で、リトライしたら取得できる範囲で標準出力が以下。
[2013-05-02T08:18:40+00:00] FATAL: You must set node['mysql']['server_debian_password'], node['mysql']['server_root_password'], node['mysql']['server_repl_password'] in chef-solo mode. For more information, see https://github.com/opscode-cookbooks/mysql#chef-solo-note ================================================================================ Recipe Compile Error in /home/vagrant/chef-solo/cookbooks-1/wordpress/recipes/default.rb ================================================================================ SystemExit ---------- exit Cookbook Trace: --------------- /home/vagrant/chef-solo/cookbooks-1/mysql/recipes/server.rb:32:in `from_file' /home/vagrant/chef-solo/cookbooks-1/wordpress/recipes/default.rb:21:in `from_file' Relevant File Content: ---------------------- /home/vagrant/chef-solo/cookbooks-1/mysql/recipes/server.rb: 25: missing_attrs = %w{ 26: server_debian_password server_root_password server_repl_password 27: }.select do |attr| 28: node["mysql"][attr].nil? 29: end.map { |attr| "node['mysql']['#{attr}']" } 30: 31: if !missing_attrs.empty? 32>> Chef::Application.fatal!([ 33: "You must set #{missing_attrs.join(', ')} in chef-solo mode.", 34: "For more information, see https://github.com/opscode-cookbooks/mysql#chef-solo-note" 35: ].join(' ')) 36: end 37: else 38: # generate all passwords 39: node.set_unless['mysql']['server_debian_password'] = secure_password 40: node.set_unless['mysql']['server_root_password'] = secure_password 41: node.set_unless['mysql']['server_repl_password'] = secure_password [2013-05-02T08:18:40+00:00] ERROR: Running exception handlers [2013-05-02T08:18:40+00:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated ERROR: RuntimeError: chef-solo failed. See output above.
以下な変数をナニらしい。
- node['mysql']['server_debian_password']
- node['mysql']['server_root_password']
- node['mysql']['server_repl_password']
こうするのかな (nodes/192.168.33.10.json)。
{ "mysql":[ "server_debian_password":"rms", "server_root_password":"rms", "server_repl_password":"rms" ], "run_list":["wordpress"] }
リトライ。どうなるか。
"server_debian_password":"rms", "server_root_pa
むがくく。スペース空ければ良いのかな。array element って出てるな。あ、ブラケットじゃなくてブレイスだった。以下で良いのかどうか。
{ "mysql":{ "server_debian_password":"rms", "server_root_password":"rms", "server_repl_password":"rms" }, "run_list":["wordpress"] }
でリトライ中なんですが、色々ぶりぶり動いていらっしゃるご様子。これは cookbooks 配下の掘削が大変じゃないかな。現時点でげんなりする位の標準出力な情報です。
で、待たせた挙句以下で終了。
[2013-05-02T08:40:01+00:00] ERROR: Running exception handlers [2013-05-02T08:40:01+00:00] ERROR: Exception handlers complete Chef Client failed. 42 resources updated [2013-05-02T08:40:01+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out [2013-05-02T08:40:01+00:00] FATAL: LoadError: execute[create wordpressdb database] (wordpress::default line 76) had an error: LoadError: cannot load such file -- mysql ERROR: RuntimeError: chef-solo failed. See output above.
仮想ホストに入って確認してみるに
ということで中身を見てみます。以下あたりらしい。
execute "create #{node['wordpress']['db']['database']} database" do command "/usr/bin/mysqladmin -u root -p\"#{node['mysql']['server_root_password']}\" create #{node['wordpress']['db']['database']}" not_if do require 'mysql' m = Mysql.new("localhost", "root", node['mysql']['server_root_password']) m.list_dbs.include?(node['wordpress']['db']['database']) end notifies :create, "ruby_block[save node data]", :immediately unless Chef::Config[:solo] end
require 'mysql' というソレが見えますがこれは一体何でしょ。おそらくはこれが、なはずなんですが。
つうか、https://github.com/opscode-cookbooks/mysql の README.md 見てるに nodes なソレは以下でないと、らしい件。
{ "mysql": { "server_root_password": "iloverandompasswordsbutthiswilldo", "server_repl_password": "iloverandompasswordsbutthiswilldo", "server_debian_password": "iloverandompasswordsbutthiswilldo" }, "run_list":["recipe[mysql::server]"] }
修正して、一旦 vagrant destroy してイチからナニ。
$ vagrant up $ cd chef-repo $ knife solo cook 192.168.33.10
あら、knife solo prepare しないといけないらしい。こうするか。
$ knife solo prepare vagrant@192.168.33.10
これヤッた上でこうするとどうなるかな。
$ knife solo cook 192.168.33.10
動きました。ここも上手な方法はあるはずですが。。
終了
* service[mysql] action restart - restart service service[mysql] * service[mysql] action start (up to date) Chef Client finished, 15 resources updated
終わりよった。でも 80 は開いてないし apache なプロセスも居ない。
って、よくよく見てみたら nodes/192.168.33.10.json で指定したソレって mysql のだったよ。つうかこれって sahara 使わないと、なのかどうか。
で、nodes なソレを修正してここで kickoff してみたらどうなるんだろ。
つうか結局 require 'mysql' なソレは解決してないのかorz
こうすりゃ良いの?
一部のみですが。
"run_list":["wordpress", "recipe[mysql::ruby]"]
これ、sahara で云々なソレで試します。とりあえず vagrant up を。起動したら以下かな。
$ vagrant sandbox on 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
これで vagrant sandbox rollback でここに戻せると。ゆーことは、knife solo prepare した状態で commit しなきゃ、なのか。
$ cd chef-solo $ knife solo prepare vagrant@192.168.33.10 $ cd .. $ vagrant sandbox commit
で、knife solo cook を kickoff か。
$ knife solo cook 192.168.33.10
あとは vagrant sandbox rollback で元に戻せる、のかな? つうか commit は時間かかりますね。off して on した方が早いのかどうか。
終わった
なんとなく正常終了してそげ
Recipe: apache2::default * service[apache2] action restart - restart service service[apache2] Chef Client finished, 19 resources updated
- 80 および 3306 なポートは開いてます
- apache2 なプロセスも起動されている
- /etc/apache2/sites-enabled/wordpress.conf が居る
- ブラウザでのアクセスは無理かなと言いつつアレしてみたらリダイレクトされてるな
とりあえず git なリポジトリをアレしてこの時点のナニを保存しとこ。ここでエントリ投入しますが、cookbook 掘削対応したらメモを追記するかもしれません。