编写一个安装ruby系统版本的配方,安装破折号并在精简版上部署破折号。要安装ruby,我在我的配方中使用以下社区食谱https://github.com/fnichol/chef-ruby_build,它在提供的路径上安装ruby和所需的gem,即/ usr / local / project_name / ruby。 (注意:这不会将已安装的ruby路径添加到PATH变量)当我运行chef-client时,它总是试图查看omnibus ruby路径(/ opt / chef / embedded / ruby)并尝试找到宝石在它下面可用,因此它无法在其源代码中运行破坏,这需要捆绑和精简。以下是配方,我在skyboxlabs上使用chef-cluster 10.24v运行它。有没有办法在运行chef-client时指定要使用的已安装ruby路径?
# Cookbook Name:: program_dashboard
# Recipe:: default
include_recipe "ruby_build"
branch_name = node['program-dashboard']['branch_or_tag']
ruby_version = node['ruby']['version']
repo_url = node['dashboard_repo']
ruby_prefix_path = node['ruby']['prefix_path']
dashboard_repo_path = node['dashboard_repo_path']
ruby_home = ::File.expand_path('bin',ruby_prefix_path)
dashing = ::File.expand_path('dashing', ruby_home)
bundle_install = "#{::File.expand_path('bundle', ruby_home)} install"
package 'git' do
action :install
not_if "which git"
end
ruby_build_ruby ruby_version do
user "root"
prefix_path ruby_prefix_path
definition ruby_version
action :install
end
#Getting the latest from repository
log "Getting the latest from the program-dev-dashboard repo"
git dashboard_repo_path do
repository repo_url
reference branch_name
user "root"
end
%w{bundler dashing}.each do |pkg|
gem_package pkg do
gem_binary "#{ruby_home}/gem"
end
end
execute bundle_install do
cwd dashboard_repo_path
not_if "bundle check --gemfile #{::File.expand_path('Gemfile',dashboard_repo_path)}"
end
#Cycle the webserver
log "Getting the Dashboard Up and Running"
bash "cycle server" do
user "root"
cwd dashboard_repo_path
flags "-e"
code <<-EOH
echo "Stopping the dashing server"
#{dashing} stop //fails here [1]
echo "Starting the dashing server"
#{dashing} start -d
EOH
end
[1]因为破坏调用捆绑exec瘦命令,而这些命令在omnibus ruby中找不到,所以如何让chef-client在已安装的ruby路径中查找宝石。