Chefからsensuをインストールする時にerlang導入で失敗する
sensuをChefでインストールしようとすると、途中でエラーになって止まります。
Sensu | An open source monitoring framework
Recipe: erlang::package * package[erlang] action install ================================================================================ Error executing action `install` on resource 'package[erlang]' ================================================================================ Chef::Exceptions::Exec ---------------------- returned 1, expected 0 Resource Declaration: --------------------- # In /root/chef-repo/cookbooks/erlang/recipes/package.rb 46: package 'erlang' 47: end Compiled Resource: ------------------ # Declared in /root/chef-repo/cookbooks/erlang/recipes/package.rb:46:in `from_file' package("erlang") do action :install retries 0 retry_delay 2 package_name "erlang" version "R16B03-0.2.el6" cookbook_name :erlang recipe_name "package" end
そこで、以下の記事を見つけたので、それを試してみました。
CentOS 6.5でChefからSensuをインストールしようとするとRabbitMQでコケる回避策 - さよならインターネット
こちらの記事ではRabbitMQ起動時に失敗するとのことでしたが、自分の環境ではインストール時に失敗します。
そして、上記の記事の通り、以下のようにrecipeを書き換えて実行…しても、止まってしまいました。
diff --git cookbooks/erlang/recipes/package.rb cookbooks/erlang/recipes/package.rb index 19f9fce..6cec68f 100644 --- cookbooks/erlang/recipes/package.rb +++ cookbooks/erlang/recipes/package.rb @@ -43,5 +43,9 @@ when 'rhel' include_recipe 'yum-erlang_solutions' end - package 'erlang' + execute "yum install -y erlang-R16B02" do + user "root" + command "yum install -y erlang-R16B02" + not_if { File.exists? "/usr/bin/erl" } + end end
そこで結局取ったのは、上記erlang
インストールに入る前に、そもそもインストールしてしまうという強引な方法…。
以下のコードをcookbooks/sensu/recipes/default.rb
に記載します。
include_recipe "yum-epel" package "erlang" do action :install options "--enablerepo=epel" end
これで、Chefでインストールが通るようになりました。
これ、結局ryuzeeさんの方法なんですよね。
ryuzeeさんがなぜwrapperのcookbookを作って、わざわざerlang
を先にインストールしているのかがようやく分かりました。
Sensuを使って自由度の高い監視システムの構築を行う方法 | Ryuzee.com
https://github.com/ryuzee-cookbooks/sensu-server-wrapper