Enable Custom and Open-Source Cookbooks in AWS OpsWorks Stack

Enable Custom and Open-Source Cookbooks

Prev Question Next Question

Question

You have an AWS OpsWorks Stack running Chef Version 11.10

Your company hosts its own proprietary cookbook on Amazon S3, and this is specified as a custom cookbook in the stack.

You want to use an open-source cookbook located in an external Git repository.

What tasks should you perform to enable the use of both custom cookbooks?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - A.

To use an external cookbook on an instance, you need a way to install it and manage any dependencies.

The preferred approach is to implement a cookbook that supports a dependency manager named Berkshelf.

Berkshelf works on Amazon EC2 instances, including AWS OpsWorks Stacks instances, but it is also designed to work with Test Kitchen and Vagrant.

For more information on Opswork and Berkshelf, please visit the link:

http://docs.aws.amazon.com/opsworks/latest/userguide/cookbooks-101-opsworks-berkshelf.html

To use both a custom cookbook stored on Amazon S3 and an open-source cookbook located in an external Git repository in an AWS OpsWorks Stack running Chef Version 11.10, you need to perform the following tasks:

Option A: In the AWS OpsWorks stack settings, enable Berkshelf. Create a new cookbook with a Berksfile that specifies the other two cookbooks. Configure the stack to use this new cookbook.

Berkshelf is a dependency manager for Chef cookbooks. It allows you to manage cookbooks from various sources, including Git repositories and Amazon S3. By enabling Berkshelf in your AWS OpsWorks stack settings, you can use it to manage dependencies between the custom and open-source cookbooks.

To enable Berkshelf, follow these steps:

  1. In the AWS OpsWorks console, select the stack you want to configure.
  2. Click on the "Stack Settings" button in the left-hand menu.
  3. Scroll down to the "Cookbook settings" section and select "Berkshelf" from the "Cookbook source" dropdown.
  4. Click the "Save changes" button.

Next, create a new cookbook with a Berksfile that specifies the other two cookbooks:

  1. In the AWS OpsWorks console, select the stack you want to configure.
  2. Click on the "Stack Settings" button in the left-hand menu.
  3. Scroll down to the "Cookbooks" section and click the "Add cookbook" button.
  4. Enter a name for your new cookbook, and select "Berkshelf" from the "Source type" dropdown.
  5. In the "Berksfile" section, specify the two cookbooks you want to use, including the custom cookbook stored on Amazon S3 and the open-source cookbook located in the external Git repository. For example:

source 'https://supermarket.chef.io'

cookbook 'my_custom_cookbook', git: 'https://github.com/myorg/my_custom_cookbook.git' cookbook 'open_source_cookbook', git: 'https://github.com/open-source-project/open_source_cookbook.git'

  1. Click the "Add cookbook" button.

Finally, configure the stack to use this new cookbook:

  1. In the AWS OpsWorks console, select the stack you want to configure.
  2. Click on the "Stack Settings" button in the left-hand menu.
  3. Scroll down to the "Cookbooks" section and click the "Edit" button next to "Custom cookbooks".
  4. Select your new cookbook from the dropdown.
  5. Click the "Save changes" button.

Option B: In the OpsWorks stack settings add the open source project's cookbook details in addition to your cookbook.

This option is not recommended, as it can lead to dependency conflicts and make it difficult to manage the cookbooks. However, if you choose this option, you can follow these steps:

  1. In the AWS OpsWorks console, select the stack you want to configure.
  2. Click on the "Stack Settings" button in the left-hand menu.
  3. Scroll down to the "Cookbooks" section and click the "Add cookbook" button.
  4. Enter the details for the open-source cookbook, including the Git repository URL, branch or tag name, and any other required parameters.
  5. Click the "Add cookbook" button.

Option C: Contact the open-source project's maintainers and request that they pull your cookbook into theirs. Update the stack to use their cookbook.

This option is not recommended, as it requires coordination with the maintainers of the open-source cookbook and may not be feasible in all cases.

Option D: In your cookbook create an S3 symlink object that points to the open source project's cookbook.

This option is not recommended, as it can cause issues