This content is part of the Essential Guide: An OpenStack management guide for the enterprise

Infuse more flexibility into OpenStack Heat templates

OpenStack admins use Heat templates to streamline cloud resource deployment. What are the templates' main components, and how can we use them in more flexible ways?

OpenStack Heat is the orchestration component within the open source cloud platform. Admins can use Heat to deploy a full cloud stack, consisting of any number of VMs and associated configurations. To deploy stacks using OpenStack Heat, admins need to create a template in Heat Object Template format.

An OpenStack Heat template is written in YAML Ain't Markup Language, and everything in it is passed in YAML format. This includes the template file itself, as well as the additional properties that need to be processed in the Heat Object Template (HOT). Admins can write template files in a static way that contains all the required parameters, but that's not always flexible enough for stack deployments in an ever-changing environment such as OpenStack.

OpenStack Heat example with environment files

To work with parameters in a more flexible way, admins can use OpenStack Heat environment files. Then, the HOT is processed by the heat command together with the environment file. In the template itself, admins set variables to refer to specific parameters and can define these parameters in the HOT itself -- which is the case in the example in Listing 1 below -- or in an environment file.

OpenStack components
Learn about OpenStack's major components.

In this example, you can see the variable is referred to by using the curly braces: { get_resource: volume }.

This refers to the volume parameter, which admins define later in the template file. The term resources refers to the specific OpenStack components -- such as compute instances and security groups -- admins want to deploy.

Listing 1: Sample HOT contents

heat_template_version: 2014-10-16

description: A simple server



    type: OS::Nova::Server



        - device_name: vda

          delete_on_termination: true

          volume_id: { get_resource: volume }

      flavor: m1.nano


        - network: internal001

      user_data_format: RAW

      user_data: |


        while [ 1 ]; do echo $((13**99)) 1>/dev/null 2>&1; done


    type: OS::Cinder::Volume


      image: 'Cirros 0.3.4'

      size: 1

When admins define and use additional parameters in environment files, they have more flexibility with OpenStack Heat, especially as it increases scalability. To deploy a private cloud stack with both the HOT and the environment file, run the heat command, as in heat stack-create -r -f my-template.yaml -e my-env.yaml my-stack. Here, the -f option refers to the HOT, and the -e option refers to the environment file.

Environment files are not the only option for increased flexibility; admins could also include specific parameters when they run the heat command with the -P key=value argument.

Next Steps

Modify the OpenStack Horizon dashboard to fit your needs

Strengthen your OpenStack management strategy

Explore four ways to start and restart OpenStack instances

Dig Deeper on Open source cloud computing