我做了一些研究,但找不到任何令人满意的东西。我们正在使用 Chef 11。
这就是我现在所拥有的。仅供引用:我对 Chef 很陌生。所以我有一种直觉,我做错了。
execute "Update apt-get" do
command 'curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -'
end
package 'nodejs' do
action :upgrade
end
它大部分时间都有效。但它有时会失败。
Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
This issue on ubuntu似乎是罪魁祸首。
问题是,有没有比运行这个
curl
更好的方法?更新命令apt-get
所以我可以安装更高版本的node.js?
最佳答案
我使用以下说明书使用 chef 管理一些 Node.js 应用程序:application , application_git , application_javascript
配方如下:
include_recipe 'chef-vault'
# provisions system user to run application
user node['project']['application']['user'] do
system true
shell '/bin/false'
manage_home true
end
application node['project']['application']['deploy_path'] do
# Provision specific Node.js version
javascript '4.2.4'
owner node['project']['application']['user']
group node['project']['application']['user']
# Download application source from git private repository
git node['project']['application']['repository'] do
deploy_key chef_vault_item('project', 'deploy_key')['file-content']
end
# install dependencies
npm_install do
production false
user node['project']['application']['user']
group node['project']['application']['user']
end
# Provision service
javascript_service 'server.js'
end
project
在我的 Recipe 中是已部署的特定项目的名称。这个 Recipe 有一些优点:
关于node.js - 使用 chef 在 aws 上安装 node.js 的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45042572/