简体   繁体   English

为什么我的自定义配方无法在AWS OpsWorks上运行?

[英]Why doesn't my custom recipes run on AWS OpsWorks?

I've created a GitHub repo for my simple custom recipe: 我已经为我的简单自定义食谱创建了GitHub存储库:

my-cookbook/
|- recipes/
   |- appsetup.rb

I've added the repo to Custom Chef Recipes as https://github.com/my-github-user/my-github-repo.git 我已将仓库添加到自定义厨师食谱中, https://github.com/my-github-user/my-github-repo.githttps://github.com/my-github-user/my-github-repo.git

I've added my-cookbook::appsetup to the Setup "cycle". 我已经将my-cookbook::appsetup添加到安装程序的“周期”中。

I know it's executed, because it fails to load if I mess up the syntax. 我知道它已执行,因为如果我弄乱了语法,它就无法加载。

This is my appsetup.rb: 这是我的appsetup.rb:

node[:deploy].each do |app_name, deploy|
  script "install_composer" do
    interpreter "bash"
    user "root"
    cwd "#{deploy[:deploy_to]}/current"
    code "curl -sS https://getcomposer.org/installer | php && php composer.phar install --no-dev"
  end
end

When I log into the instance by SSH with the ubuntu user, composer isn't installed. 当我使用ubuntu用户通过SSH登录实例时,未安装composer。

I've also tried the following to no avail (A nodejs install): 我也尝试了以下无济于事(安装nodejs):

node[:deploy].each do |app_name, deploy|
  execute "installing node" do
    command "add-apt-repository --yes ppa:chris-lea/node.js && apt-get update && sudo apt-get install python-software-properties python g++ make nodejs"
  end
end

Node doesn't get installed, and there are no errors in the log. 节点未安装,并且日志中没有错误。 The only references to the cookbook in the log just says: 日志中对食谱的唯一引用只是说:

[2014-03-31T13:26:04+00:00] INFO: OpsWorks Custom Run List: ["opsworks_initial_setup", "ssh_host_keys", "ssh_users", "mysql::client", "dependencies", "ebs", "opsworks_ganglia::client", "opsworks_stack_state_sync", "mod_php5_apache2", "my-cookbook::appsetup", "deploy::default", "deploy::php", "test_suite", "opsworks_cleanup"]
...
2014-03-31T13:26:04+00:00] INFO: New Run List expands to ["opsworks_initial_setup", "ssh_host_keys", "ssh_users", "mysql::client", "dependencies", "ebs", "opsworks_ganglia::client", "opsworks_stack_state_sync", "mod_php5_apache2", "my-cookbook::appsetup", "deploy::default", "deploy::php", "test_suite", "opsworks_cleanup"]
...
[2014-03-31T13:26:05+00:00] DEBUG: Loading Recipe my-cookbook::appsetup via include_recipe
[2014-03-31T13:26:05+00:00] DEBUG: Found recipe appsetup in cookbook my-cookbook

Am I missing some critical step somewhere? 我是否在某个地方错过了一些关键步骤? The recipe is clearly recognized and loaded, but doesn't seem to be executed. 可以清楚地识别并加载该配方,但是似乎没有执行该配方。

(The following are fictitious names: my-github-user, my-github-repo, my-cookbook) (以下为虚拟名称:my-github-user,my-github-repo,my-cookbook)

我知道您已经放弃了菜谱,但是我几乎100%确信这是因为您在菜谱的根目录中没有metadata.rb文件。

Your cookbook name should not contain a dash. 您的食谱名称不应包含破折号。 I had the same problem, replacing by '_' solved it for me. 我遇到了同样的问题,用“ _”代替为我解决了。

If those commands are failing silently, it could be that your use of && is obscuring a failure. 如果这些命令无提示地失败,则可能是您对&&的使用掩盖了失败。

As for add-apt-repository, that is an interactive command. 至于add-apt-repository,这是一个交互式命令。 Try using the "--yes" option to answer yes by default, making it no longer interactive. 尝试使用“ --yes”选项在默认情况下回答yes,使其不再具有交互性。

If you do not execute your command successfully, you will not find the files in the current directory. 如果未成功执行命令,则不会在当前目录中找到文件。 Check inside the last release folder to see if it had been put there. 检查最后一个发行文件夹中的内容是否已放置在该文件夹中。

It maybe prudent to check if you got the right directory etc setup by changing the CWD to : /tmp 通过将CWD更改为:/ tmp来检查是否具有正确的目录等设置可能是明智的选择

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM