Getting Started with Cookbooks in AWS OpsWorks - AWS OpsWorks. A production-level AWS OpsWorks stack typically requires some customization, which often means implementing a custom Chef cookbook.
A cookbook is a package file that contains configuration information, including instructions called recipes. A recipe is a set of one or more instructions, written with Ruby language syntax, that specifies the resources to use and the order in which those resources are applied. GitHub - chef/chef: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure. Learning More: Explore the Cookbook Used in This Walkthrough - AWS OpsWorks.
This topic describes the cookbook that AWS OpsWorks used for the walkthrough.
A cookbook is a Chef concept. Cookbooks are archive files that contain configuration information, such as recipes, attribute values, files, templates, libraries, definitions, and custom resources. A recipe is also a Chef concept. Recipes are instructions, written with Ruby language syntax, that specify the resources to use and the order in which those resources are applied. For more information, go to About Cookbooks and About Recipes on the Learn Chef website. To see the contents of the cookbook used in this walkthrough, extract the contents of the opsworks-linux-demo-cookbooks-nodejs.tar.gz file to an empty directory on your local workstation. The default.rb file in the cookbooks/nodejs_demo/recipes directory is where the cookbook start running its code: Here's what the file does: About Recipes. A recipe is the most fundamental configuration element within the organization.
A recipe: Recipe Attributes An attribute can be defined in a cookbook (or a recipe) and then used to override the default settings on a node. When a cookbook is loaded during a chef-client run, these attributes are compared to the attributes that are already present on the node. Attributes that are defined in attribute files are first loaded according to cookbook order. Note Attributes can be configured in cookbooks (attribute files and recipes), roles, and environments. Attribute Types The chef-client uses six types of attributes to determine the value that is applied to a node during the chef-client run. Attribute Persistence. Deploying Apps - AWS OpsWorks. The primary purpose of deployment is to deploy application code and related files to application server instances.
The deployment operation is handled by each instance's Deploy recipes, which are determined by the instance's layer. When you start an instance, after the Setup recipes complete, AWS OpsWorks automatically runs the instance's Deploy recipes. However, when you add or modify an app, you must deploy it manually to any online instances. You must have Manage or Deploy permissions to deploy an app. For more information, see Managing User Permissions. To deploy an app On the Apps page, click the app's deploy action.TipYou can also deploy an app by clicking Deployments in the navigation pane. Tip When you deploy an update to a JSP app, Tomcat might not recognize the update and instead continue to run the existing app version. <context-param><param-name>appVersion</param-name><param-value>0.1</param-value></context-param> Undeploy Rollback Restores the previously deployed app version. Apps - AWS OpsWorks.
Layers - AWS OpsWorks. Every stack contains one or more layers, each of which represents a stack component, such as a load balancer or a set of application servers.
As you work with OpsWorks layers, keep the following in mind: Each layer in a stack must have at least one instance and can optionally have multiple instances.Each instance in a stack must be a member of at least one layer, except for registered instances.You cannot configure an instance directly, except for some basic settings such as the SSH key and hostname. You must create and configure an appropriate layer, and add the instance to the layer. Amazon EC2 instances can optionally be a member of multiple OpsWorks layers. In that case, AWS OpsWorks runs the recipes to install and configure packages, deploy applications, and so on for each of the instance's layers.
By assigning an instance to multiple layers, you could, for example do the following: Getting Started with Linux Stacks - AWS OpsWorks. In this walkthrough, you will learn how to use AWS OpsWorks to create a Node.js application environment.
When you are done, you will have an Amazon Elastic Compute Cloud (Amazon EC2) instance running Chef 12, a Node.js HTTP server, and a web app that you can use to interact with Twitter and leave comments on a web page. Chef is a third-party framework for configuring and maintaining servers, such as EC2 instances, and how apps are deployed and maintained on those servers. If you aren't familiar with Chef, after completing this walkthrough, we recommend that you learn more about Chef so that you can take full advantage of all that AWS OpsWorks has to offer.
(For more information, go to the Learn Chef website.) AWS OpsWorks supports three Linux distributions: Amazon Linux, Ubuntu Server, and Red Hat Enterprise Linux. Learn Chef.