简体   繁体   中英

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

I've created a GitHub repo for my simple custom recipe:

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

I've added my-cookbook::appsetup to the Setup "cycle".

I know it's executed, because it fails to load if I mess up the syntax.

This is my 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.

I've also tried the following to no avail (A nodejs install):

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)

我知道您已经放弃了菜谱,但是我几乎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. Try using the "--yes" option to answer yes by default, making it no longer interactive.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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