6. メインディッシュ
(現時点でのベストプラティクス)
• とりあえず remote_̲file を使うことで悩みを解決
# rpmforge リポジトリのインストール
remote_̲file "/tmp/rpmforge-‐‑‒release-‐‑‒0.5.2-‐‑‒2.el6.rf.i686.rpm" do
source "http://pkgs.repoforge.org/rpmforge-‐‑‒release/rpmforge-‐‑‒
release-‐‑‒0.5.2-‐‑‒2.el6.rf.i686.rpm"
end
package "rpmforge" do
action :install
source "/tmp/rpmforge-‐‑‒release-‐‑‒0.5.2-‐‑‒2.el6.rf.i686.rpm"
provider Chef::Provider::Package::Rpm
end
7. おかわり
(redis をソースコードから導⼊入して起動まで)
• not_̲if で制御してみました…
# ソースコードの取得からインストールまで
remote_̲file "/usr/local/src/redis-‐‑‒2.6.9.tar.gz" do
source "http://redis.googlecode.com/files/redis-‐‑‒2.6.9.tar.gz"
notifies :run, "bash[install_̲program]", :immediately
end
bash "install_̲program" do
not_̲if "ls /usr/local/bin/redis-‐‑‒server"
user "root"
cwd "/usr/local/src"
code <<-‐‑‒EOH
tar -‐‑‒zxf redis-‐‑‒2.6.9.tar.gz
(cd redis-‐‑‒2.6.9/ && make test && make && make install)
EOH
end
# サービスの起動
bash "starting_̲redis" do
not_̲if "ps aux | grep redis-‐‑‒server |grep -‐‑‒v"
user "root"
code <<-‐‑‒EOH
/usr/local/bin/redis-‐‑‒server &
EOH
#action :nothing
end