Heat - Getting Started
Overview
Heat consumes templates written in "Heat Orchestration Template" (HOT) format.
- Fully documented in the HOT specification
Heat client
You need the heat client to execute commands described in this guide
- Red Hat / Cent OS
$ sudo yum install python3-heatclient
- Debian / Ubuntu
$ sudo apt install python3-heatclient
- Using Pip
$ pip3 install python3-heatclient
Complete Example
Here you can find a complete working template for infomaniak Openstack Public Cloud.
heat_template_version: 2015-04-30
description: Simple template to deploy a single compute instance
parameters:
instance_name:
type: string
description: VM Name
constraints:
- allowed_pattern: "[a-zA-Z0-9-]+"
resources:
heatinstance:
type: OS::Nova::Server
properties:
name: { get_param: instance_name }
key_name: my_key
image: "Debian 11 bullseye"
flavor: a2-ram4-disk20-perf1
networks: [ "network": ext-net1 ]
Structure
Templates have a header and three sections:
- heat_template_version
heat_template_version: 2015-04-30
Mandatory. The heat_template_version value is required and states which format is used in the present template.
Only certain values are valid, such as rocky, 2018-08-31, queens, 2018-03-02, etc. There's not much to understand here, just pick up a value.
- parameters
We can replace hardcoded values with parameters:
parameters: # parameters go here
parameters:
image:
type: string
default: "Debian 11 bullseye"
description: >
image name or id used to boot our nova servers
Parameters can have:
Types
(string, number, comma_delimited_list, json, or boolean)
Descriptions
Constraints
("must be less than", "must be one of the following values", etc)
When creating a stack, parameters can be specified:
On the command line with --parameter
:
openstack stack create -t my_stack.yaml --parameter image="Centos 8" my_stack
On the command line using an environment file:
openstack stack create -t my_stack.yaml -e my_env.yaml my_stack
An environment file is a YAML file with a parameters section containing values for parameters declared in your template:
The content of my_env.yaml
can be for example :
parameters:
image: "Centos 8"
Resources The resources section specifies what resources Heat should create:
- resources
resources: # resources go here (this section is required) example : my_resource_id: type: a_resource_type properties: property1: ... property2: ...
Resources can depend on other resources. Explicitly:
my_server:
type: "OS::Nova::Server"
depends_on: my_network
- outputs
outputs: # outputs go here
You can define what will be printed after you launched the openstack stack create command. Usually you want to know the IP addresses of the VMs and the associated hostname.
outputs:
server_ip:
description: fixed ip assigned to the server
value: { get_attr: [my_server, first_address] }
These outputs will be printed when calling openstack stack show <stack-name>
Resource Documentation
Online documentation includes list of available resource types. You should refer to that document whenever you need a new resource.
You can also query Heat for information about available resource types:
$ openstack orchestration resource type list
+------------------------------------------+
| resource_type |
+------------------------------------------+
[...]
| OS::Nova::FloatingIP |
| OS::Nova::FloatingIPAssociation |
| OS::Nova::KeyPair |
| OS::Nova::Server |
[...]
And for information about a specific type:
$ openstack orchestration resource type show OS::Nova::Server
HeatTemplateFormatVersion: '2012-12-12'
Outputs:
accessIPv4: {Description: The manually assigned alternative public IPv4 address
of the server., Value: '{"Fn::GetAtt": ["Server", "accessIPv4"]}'}
Parameters:
admin_pass: {Description: The administrator password for the server., Type: String}
Resources:
Server:
Properties:
admin_pass: {Ref: admin_pass}
Type: OS::Nova::Server
Outputs