chef-solo 在安装 redis 时挂起,好像厨师正在等待某些事件发生。这是我不得不用 ctrl+c 杀死它时的输出。
[2013-05-14T15:55:27+00:00] 错误:运行异常处理程序
[2013-05-14T15:55:27+00:00] 错误:异常处理程序完成 Chef Client 失败。8 个资源已更新
[2013-05-14T15:55:27+00:00] 致命:Stacktrace 转储到 /home/ubuntu/cache/chef-stacktrace.out [2013-05-14T15:55:27+00:00]致命:Chef::Exceptions::MultipleFailures:发生多个故障:
* SystemExit 在 chef 运行中发生:service[redis](redis::default line 107)有一个错误:SystemExit:exit
* Chef::Exceptions::Exec 发生在延迟通知:service[redis](redis::default 第 83 行)出错:Chef::Exceptions::Exec: /sbin/start redis 返回 1,预期为 0
我是厨师新手,无法弄清楚为什么会这样。以前有没有人注意到这种行为?
这是我的食谱文件
package "build-essential" do
action :install
end
user node[:redis][:user] do
action :create
system true
shell "/bin/false"
end
directory node[:redis][:dir] do
owner node[:redis][:user]
group node[:redis][:user]
mode "0755"
action :create
end
directory node[:redis][:data_dir] do
owner node[:redis][:user]
group node[:redis][:user]
mode "0755"
action :create
end
directory node[:redis][:log_dir] do
owner node[:redis][:user]
group node[:redis][:user]
mode "0755"
action :create
end
remote_file "#{Chef::Config[:file_cache_path]}/redis-2.6.10.tar.gz" do
source "http://redis.googlecode.com/files/redis-2.6.10.tar.gz"
action :create_if_missing
end
# Adding 'make test' causes the install to freeze for some reason.
bash "compile_redis_source" do
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar zxf redis-2.6.10.tar.gz
cd redis-2.6.10
make && sudo make install
# to give permissions to the executables that it copied to.
chown -R redis:redis /usr/local/bin
EOH
creates "/usr/local/bin/redis-server"
end
service "redis" do
provider Chef::Provider::Service::Upstart
subscribes :restart, resources(:bash => "compile_redis_source")
supports :restart => true, :start => true, :stop => true
end
template "redis.conf" do
path "#{node[:redis][:dir]}/redis.conf"
source "redis.conf.erb"
owner node[:redis][:user]
group node[:redis][:user]
mode "0644"
notifies :restart, resources(:service => "redis")
end
template "redis.upstart.conf" do
path "/etc/init/redis.conf"
source "redis.upstart.conf.erb"
owner node[:redis][:user]
group node[:redis][:user]
mode "0644"
notifies :restart, resources(:service => "redis")
end
service "redis" do
action [:enable, :start]
end
有 2 个服务“redis”资源语句,有问题吗?或者在这种情况下厨师如何锻炼,它在运行时是否合并为单个资源?
我正在使用新贵,这里是 redis.upstart.conf.erb 文件。不确定这是否有任何问题。该文件中语句的顺序是否重要?
#!upstart
description "Redis Server"
emits redis-server
# run when the local FS becomes available
start on local-filesystems
stop on shutdown
setuid redis
setgid redis
expect fork
# Respawn unless redis dies 10 times in 5 seconds
#respawn
#respawn limit 10 5
# start a default instance
instance $NAME
env NAME=redis
#instance $NAME
# run redis as the correct user
#setuid redis
#setgid redis
# run redis with the correct config file for this instance
exec /usr/local/bin/redis-server /etc/redis/redis.conf
respawn
#respawn limit 10 5