edo1z blog

プログラミングなどに関するブログです

Vagrantの設定 - chefが動かない

今CentOS6.5のVagrantのboxをaddしまして、vagrant upを行いました。mountエラーが出ましたが、Vagrant mountエラーここの内容で解決しました。

しかしchefが機能しません。前回何をやったのかもう忘れました。chefも全然まだ詳しくないのでどっかのブログを真似ただけだったのですがどのブログか忘れました。あ、そういえば仮想マシンに対して何かchef関連のコマンドを実行してた気がする。 というかchef-repoっていうディレクトリを作成したんだった。これをコピーしてみよう。どうやってつくったか忘れた。

$ vagrant provision
[default] Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.

うむまだエラーが出る。あのブログを探そう。なんていう他人本意なんだ。まあいい今は。 発見!

Vagrantの使い方 (2) Chefを使ってApache、PHP、MySQLをインストールするこれこれ。 これだ仮想マシン向けのコマンド。

$ knife solo prepare hoge

このhogeは、下記コマンドで設定できるんだな。

vagrant ssh-config --host hoge >> ~/.ssh/config

こうすると、ssh hogeで仮想マシンに接続できるのだ。

$ knife solo prepare hogeをやったら成功した。では改めてvagrant provisionしてみます。

$ vagrant provision
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
[2014-03-02T07:37:05+00:00] INFO: Forking chef instance to converge...
[2014-03-02T07:37:05+00:00] INFO: *** Chef 11.10.4 ***
[2014-03-02T07:37:05+00:00] INFO: Chef-client pid: 3193
[2014-03-02T07:37:06+00:00] INFO: Setting the run_list to ["recipe[lamp]"] from JSON
[2014-03-02T07:37:06+00:00] INFO: Run List is [recipe[lamp]]
[2014-03-02T07:37:06+00:00] INFO: Run List expands to [lamp]
[2014-03-02T07:37:06+00:00] INFO: Starting Chef Run for vagrant-centos65
[2014-03-02T07:37:06+00:00] INFO: Running start handlers
[2014-03-02T07:37:06+00:00] INFO: Start handlers complete.
[2014-03-02T07:37:06+00:00] INFO: service[iptables] disabled
[2014-03-02T07:37:09+00:00] INFO: package[httpd] installing httpd-2.2.15-29.el6.centos from base repository
[2014-03-02T07:37:23+00:00] INFO: package[httpd-devel] installing httpd-devel-2.2.15-29.el6.centos from base repository
[2014-03-02T07:37:38+00:00] INFO: package[php] installing php-5.3.3-27.el6_5 from updates repository
[2014-03-02T07:37:51+00:00] INFO: package[php-devel] installing php-devel-5.3.3-27.el6_5 from updates repository
[2014-03-02T07:38:03+00:00] INFO: package[php-mbstring] installing php-mbstring-5.3.3-27.el6_5 from updates repository
[2014-03-02T07:38:14+00:00] INFO: package[php-xml] installing php-xml-5.3.3-27.el6_5 from updates repository
[2014-03-02T07:38:27+00:00] INFO: package[php-pear] installing php-pear-1.9.4-4.el6 from base repository
[2014-03-02T07:38:39+00:00] INFO: package[php-mysql] installing php-mysql-5.3.3-27.el6_5 from updates repository
[2014-03-02T07:38:50+00:00] INFO: package[mysql-server] installing mysql-server-5.1.73-3.el6_5 from updates repository
[2014-03-02T07:39:05+00:00] INFO: package[mysql-devel] installing mysql-devel-5.1.73-3.el6_5 from updates repository
[2014-03-02T07:39:20+00:00] INFO: service[httpd] enabled
[2014-03-02T07:39:25+00:00] INFO: service[httpd] started
[2014-03-02T07:39:26+00:00] INFO: service[mysqld] enabled
[2014-03-02T07:39:28+00:00] INFO: service[mysqld] started
[2014-03-02T07:39:28+00:00] INFO: Chef Run complete in 141.614846457 seconds
[2014-03-02T07:39:28+00:00] INFO: Running report handlers
[2014-03-02T07:39:28+00:00] INFO: Report handlers complete

できた。でもmysqlのバージョン古い。

yum --enablerepo=remi,epel,rpmforge -y install mysql-server

これでアップデートしたら、5.536になったけど、今度はPHPが5.45になった。うおー。chef覚えよう!今度。 yumでremoveしてもう一度installしたらphp5.3.3に戻った。だがしかし、mysqlもremoveしてみたら、インストールができなくなった(ToT)最悪。なんか5.1と5.3がごちゃごちゃになったようだ。 yum distribution-synchronizationというのをやってみたが、エラーになる。 yum install --setopt=protected_multilib=false mysqlとやってみると、ちょっと進んだけど、下記のエラーがでる。 package mysql-libs-5.5.36-1.el6.remi.x86_64 (which is newer than mysql-libs-5.1.73-3.el6_5.i686) is already installed

rpm -e --nodeps compat-mysql51-5.1.54-1.el6.remi.x86_64 rpm -e --nodeps mysql-libs-5.5.36-1.el6.remi.x86_64 yum install mysql これでとりあえずエラーでなくてインストールできた。 あー長かった。なんだろうなあ。