The two core concepts to get started with Heat are stacks and templates. A stack is a collection of resources related to one another and launched by way of a template. A template is a text document definition of a stack. To launch a Heat stack, a Heat template is launched. Let's look at both of these in more depth, starting with templates.
Before we can launch a stack, we need a template that will define the stack. There are two template formats that you can use to launch a stack in Heat. One is the AWS CloudFormation template format. If you have ever used CloudFormation in Amazon Web Services (AWS), then you will be familiar with this template format. Heat templates are very similar to those used within AWS, and add additional capabilities within OpenStack. The second format is the Heat Orchestration Template (HOT). HOT is a native Heat template format that is written in the YAML Ain't Markup Language syntax. For more examples of both, visit the Heat-templates GitHub repository and browse through the collection of example scripts. The examples used in this chapter were pulled from https://github.com/openstack/heat-templates.
Let's pull an example from the Heat-templates repository to gain some familiarity with the AWS CloudFormation format. Most of these templates are fairly large documents, so their entire contents will not be provided here. This document will be referenced from top to bottom. The document in its entirety is available at https://github.com/openstack/heat-templates/blob/master/cfn/F19/WordPress_NoKey.yaml and is also available in the code resources provided with this book.
Let's take a look at the configuration options used in this template:
InstanceType
, which references the flavors in Nova, and the DBName
, DBUsername
, DBPassword
, and DBRootPassword
properties that will be used to configure the database that will be created.80
(HTTP), and port 22
(SSH) traffic. You can also see the configuration options that will be passed to the instance when it is booted. These include packages to be installed, services to be started, the image to be used to launch the instance, which references the mappings we just looked at, the security group for the instance to reside in, and the user data that cloud-init should execute.Next, let's take a look at the HOT format before we use a template to launch a stack.
3.144.38.92