Amazon ec2 Chef尝试在EC2上部署Torquebox应用程序时失败
一般来说,我对Chef/ops很陌生,但我正在尝试在EC2上部署,我一直遇到这个错误。错误中提到的堆栈跟踪文件不存在,因此很难调试问题。此外,每当Chef失败时,我的EC2框上的权限就会被拒绝,我必须启动一个新实例。作为参考,此文件的原始来源如下: 错误如下所示:Amazon ec2 Chef尝试在EC2上部署Torquebox应用程序时失败,amazon-ec2,chef-infra,torquebox,Amazon Ec2,Chef Infra,Torquebox,一般来说,我对Chef/ops很陌生,但我正在尝试在EC2上部署,我一直遇到这个错误。错误中提到的堆栈跟踪文件不存在,因此很难调试问题。此外,每当Chef失败时,我的EC2框上的权限就会被拒绝,我必须启动一个新实例。作为参考,此文件的原始来源如下: 错误如下所示: * script[install torquebox backstage] action run - execute "bash" "/tmp/chef-script20131011-2067-1phzfkw" [20
* script[install torquebox backstage] action run
- execute "bash" "/tmp/chef-script20131011-2067-1phzfkw"
[2013-10-11T03:47:51+00:00] ERROR: Running exception handlers
[2013-10-11T03:47:51+00:00] ERROR: Exception handlers complete
[2013-10-11T03:47:51+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out
Chef Client failed. 71 resources updated
[2013-10-11T03:47:51+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.
我的配方文件-torquebox.rb:
download_file = File.join("/tmp", File.basename(node.torquebox.download_url))
remote_file download_file do
source node.torquebox.download_url
mode 00644
action :create_if_missing
notifies :run, "script[install-torquebox]", :immediately
end
script "install-torquebox" do
Chef::Log.info("Installing torquebox zip file...")
user 'torquebox'
interpreter "bash"
code <<-EOH
unzip -o #{download_file} -d /opt/torquebox/
ln -s /opt/torquebox/torquebox-2.3.2 /opt/torquebox/current
EOH
notifies :run, "execute[change ownership to torquebox]"
not_if do
File.exists? "/opt/torquebox/torquebox-2.3.2"
end
# not_if do
# File.exists? "/opt/torquebox/torquebox-2.2.0"
# end
#action :nothing
end
template "/etc/profile.d/torquebox.sh" do
source "torquebox.sh.erb"
mode 00644
owner 'root'
variables(
:jboss_user => node[:torquebox_env][:jboss_user],
:torquebox_home => node[:torquebox_env][:home],
:jboss_pidfile => node[:torquebox_env][:jboss_pidfile],
:jboss_console_log => node[:torquebox_env][:jboss_console_log],
:jboss_config => node[:torquebox][:configuration_file],
:jruby_opts => node[:torquebox_env][:jruby_opts],
:java_environment_file => node[:java][:java_environment]
)
notifies :restart, "service[jboss-as-standalone]"
end
# install torquebox backstage
#
execute "change ownership to torquebox" do
user "root"
cwd "/opt"
Chef::Log.info("changing ownership for torquebox")
command "chown -Rv 1000.1000 /opt/torquebox"
notifies :run, "script[install torquebox backstage]"
action :nothing
end
script "install torquebox backstage" do
Chef::Log.info("Installing torquebox backstage file...")
interpreter "bash"
user "torquebox"
cwd "/opt/torquebox"
code <<-EOH
export TORQUEBOX_HOME=/opt/torquebox/torquebox-2.3.2
export JAVA_HOME=/opt/jdk7/
export JBOSS_HOME=$TORQUEBOX_HOME/jboss
export JRUBY_HOME=$TORQUEBOX_HOME/jruby
export PATH=$JBOSS_HOME/bin:$JRUBY_HOME/bin:$JAVA_HOME/bin:$PATH
EOH
# jruby -S gem install torquebox-backstage
# jruby -S gem install ruby-shadow
# jruby -S backstage deploy
not_if do
File.exists? "/opt/torquebox/current/jruby/bin/backstage"
end
end
directory '/opt/apps/' do
owner "torquebox"
group "torqubox"
mode 00755
action :create
not_if do
File.exists? "/opt/apps/"
end
end
directory "/etc/jboss-as" do
owner "root"
group "root"
mode 00755
action :create
not_if do
File.exists? "/etc/jboss-as"
end
end
directory "/var/log/jboss-as" do
owner "torquebox"
group "torquebox"
mode 00755
action :create
not_if do
File.exists? "/var/log/jboss-as"
end
end
template "/etc/init.d/jboss-as-standalone" do
source "jboss-as-standalone.sh.erb"
variables(:environment_file => node[:torquebox][:environment_file])
mode 00755
owner 'root'
notifies :restart, "service[jboss-as-standalone]"
end
service "jboss-as-standalone" do
supports :status => true, :restart => true, :stop => true, :start => true
action [ :enable, :start ]
end
#if clustered then if cluster name is staging_cluster, so proxy name will be staging_cluster_proxy
#so for every cookbook, it should be paired with two of them
proxy_nodes = []
clustered_nodes = []
Chef::Log.warn("clustered status #{node[:torquebox][:clustered]}")
if node[:torquebox][:clustered]
clustered_nodes = search(:node, "roles:#{node[:torquebox][:cluster_name]}")
proxy_nodes = search(:node, "roles:#{node[:torquebox][:cluster_name]}_proxy")
template "/opt/torquebox/current/jboss/standalone/configuration/standalone-ha.xml" do
source "standalone-ha.xml.erb"
variables(:node_name => node.name, :node_ipaddress => node.ipaddress, :cluster_name => node[:torquebox][:cluster_name], :clustered_nodes => clustered_nodes, :proxy_nodes => proxy_nodes )
mode "0644"
notifies :restart, "service[jboss-as-standalone]"
end
end
if proxy_nodes.count == 0 and node[:torquebox][:clustered] == true
Chef::Log.warn("There is no proxy defined, cluster may not function")
end
if !node[:torquebox][:clustered]
template "/opt/torquebox/current/jboss/standalone/configuration/standalone.xml" do
source "standalone.xml.erb"
variables(:node_name => node.name, :node_ipaddress => node.ipaddress)
mode "0644"
notifies :restart, "service[jboss-as-standalone]"
end
end
template "/opt/torquebox/current/jboss/bin/standalone.conf" do
source "standalone.conf.erb"
mode "00644"
owner 'torquebox'
variables(:jboss_config => node[:torquebox][:configuration_file])
notifies :restart, "service[jboss-as-standalone]"
end
cookbook_file "/etc/jboss-as/jboss-as.conf" do
source "jboss-as.conf"
mode 00644
owner 'root'
end
# NGINX!
# this enables our site, kinda like a2ensite
execute 'enable-site' do
command "ln -sf /etc/nginx/sites-available/#{node[:server_name]} /etc/nginx/sites-enabled/#{node[:server_name]}"
notifies :restart, 'service[nginx]'
end
# Our configuration template. Take a look at templates/nginx.conf.erb to see what's going on.
template "/etc/nginx/sites-available/#{node[:server_name]}" do
source 'nginx.erb'
owner 'root'
group 'root'
mode 0644
notifies :run, "execute[enable-site]", :immediately
variables(
server_name: node.server_name
)
end
service 'nginx'
service 'jboss-as-standalone'
download\u file=file.join(“/tmp”,file.basename(node.torquebox.download\u url))
远程\u文件下载\u文件吗
source node.torquebox.download\u url
模式00644
操作:如果缺少,则创建
通知:立即运行“脚本[install torquebox]”
结束
脚本“安装扭矩箱”执行以下操作
Chef::Log.info(“安装torquebox zip文件…”)
用户“扭矩盒”
解释器“bash”
代码节点[:torquebox_env][:home],
:jboss_pidfile=>node[:torquebox_env][:jboss_pidfile],
:jboss_console_log=>node[:torquebox_env][:jboss_console_log],
:jboss_config=>node[:torquebox][:configuration_file],
:jruby\u opts=>node[:torquebox\u env][:jruby\u opts],
:java_环境_文件=>node[:java][:java_环境]
)
通知:重新启动,“服务[jboss作为独立服务]”
结束
#在后台安装扭矩箱
#
执行“将所有权更改为扭矩箱”执行
用户“根”
cwd“/opt”
Chef::Log.info(“更改torquebox的所有权”)
命令“chown-Rv 1000.1000/opt/torquebox”
通知:运行“脚本[install torquebox backstage]”
行动:没什么
结束
脚本“在后台安装torquebox”执行
Chef::Log.info(“安装torquebox后台文件…”)
解释器“bash”
用户“扭矩盒”
cwd“/选择/扭矩箱”
代码true,:restart=>true,:stop=>true,:start=>true
操作[:启用,:启动]
结束
#如果集群,那么如果集群名称是staging\u cluster,那么代理名称将是staging\u cluster\u proxy
#因此,对于每一本食谱,它应该与其中两本配对
代理_节点=[]
集群_节点=[]
Chef::Log.warn(“集群状态#{node[:torquebox][:集群]}”)
如果节点[:torquebox][:群集]
clustered_nodes=搜索(:node,“角色:{node[:torquebox][:cluster_name]}”)
proxy_nodes=search(:node,“角色:{node[:torquebox][:cluster_name]}\u proxy”)
模板“/opt/torquebox/current/jboss/standalone/configuration/standalone ha.xml”do
来源“standalone ha.xml.erb”
变量(:node_name=>node.name,:node_ipaddress=>node.ipaddress,:cluster_name=>node[:torquebox][:cluster_name],:clustered_nodes=>clustered_nodes,:proxy_nodes=>proxy_nodes)
模式“0644”
通知:重新启动,“服务[jboss作为独立服务]”
结束
结束
如果proxy_nodes.count==0且节点[:torquebox][:clustered]==true
Chef::Log.warn(“未定义代理,群集可能无法运行”)
结束
如果!节点[:扭矩盒][:群集]
模板“/opt/torquebox/current/jboss/standalone/configuration/standalone.xml”do
来源“standalone.xml.erb”
变量(:node\u name=>node.name,:node\u ipaddress=>node.ipaddress)
模式“0644”
通知:重新启动,“服务[jboss作为独立服务]”
结束
结束
模板“/opt/torquebox/current/jboss/bin/standalone.conf”do
来源“standalone.conf.erb”
模式“00644”
所有者“扭矩箱”
变量(:jboss_config=>node[:torquebox][:configuration_file])
通知:重新启动,“服务[jboss作为独立服务]”
结束
cookbook_file“/etc/jboss as/jboss as.conf”do
来源“jbossas.conf”
模式00644
所有者“根”
结束
#NGINX!
#这使我们的网站,有点像一个敏感
执行“启用站点”do
命令“ln-sf/etc/nginx/sites available/#{node[:server\u name]}/etc/nginx/sites enabled/#{node[:server\u name]}”
通知:重新启动“服务[nginx]”
结束
#我们的配置模板。查看templates/nginx.conf.erb以了解发生了什么。
模板“/etc/nginx/sites available/#{node[:server_name]}”do
来源“nginx.erb”
所有者“根”
“根”组
模式0644
通知:运行,“执行[启用站点]”,:立即
变数(
服务器名称:node.server\u名称
)
结束
服务“nginx”
服务“jboss作为独立版”
/tmp/chef solo/chef stacktrace.out
应该在EC2实例上,而不是本地计算机上。检查一下。你能找到解决办法吗?如果你这样做了,你可以把它贴出来,并把你的答案标记为正确的?:)