0
votes

I am pretty new to the AWS opsworks. Though I was using chef solo in some other cloud.

Currently I want to install my custom cookbook and I want to apply on my servers which is inside stack layer. Currently I am really confused how it is working in AWS.

Here are the steps i did so far - I have stored my test cookbook in github and I want to execute via chef-solo or chef-client for a test. How ever I have added the cookbook github url in stack settings. I also have added recipe in build life cycle.

I do update cookbook via run command. I can see it is running via runlist after executing all available built-in cookbooks and chef run failing with error-

no cookbook found test-cookbook

I have not configured any Json either in cookbook or while running via command. Is there anything missing?

2
Are you talking about the current-gen OpsWorks for Automate or the older OpsWorks Classic? - coderanger
Yes Noah. Currently I want run my custom cookbook via aws opsworks classic.actually i think it was my mistake.i solved it eventually. I am able to do via creating repo and then cookbook inside it. But only problem is it is using chef zero. chef zero is using wrapper cookbook like from custom cookbook it is loading the cookbook. Do we have more advantage in chef automate? I can try that too. - Biswajit Das
The newer OpsWorks is just standard Chef so all the normal workflows and tutorials apply. Up to you if that's worth switching to. - coderanger
@coderanger Just wondering is there any way to override the runlist via custom json in opsworks classic. I can see when I am executing execute_recipes via run command it is executing chef zero two times. First one with runlist - WARN: Overridden Run List: [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]] and second time with - WARN: Overridden Run List: [recipe[opsworks_stack_state_sync], recipe[test-cookbook], recipe[test_suite], recipe[opsworks_cleanup]] Here test-cookbook is custom cookbook. Any suggestion? - Biswajit Das

2 Answers

1
votes
  • Use berkshelf to create a Berksfile
  • Run berks package cookbooks.tar.gz
  • Upload cookbooks.tar.gz to AWS S3
  • In stack settings point 'Use Custom Cookbooks' to the S3 bucket
  • Run Update Cookbooks command
  • Run deploy or custom recipe you're looking to execute
0
votes

Thomas V's answer assumes that you want to use an AWS S3 instance. Newer Opsworks installs provide the option to reference a custom Github cookbook repo. Instead of pointing the stack (via stack settings) to an S3 bucket, you can use the Berks package command to grab all dependencies for your custom cookbook, which can then be uploaded to your Github repo and referenced by the stack.

From there, you should be able to use the OpsWorks options to run your custom cookbook after the required cycle (Setup, Configure, Deploy etc) by going to Layers > Recipes and adding it there.