Search code examples
openstack-heat

How to deploy an OpenStack heat template that includes a script


The orchestration engine for OpenStack 'Heat' can deploy compute resources and configure software, known as HOT templates. There are a number of examples on github here: https://github.com/openstack/heat-templates/tree/master/hot

heat templates are written in YAML and we can deploy a template with this syntax

heat stack-create my_first_stack -f heat_1a.yaml

You can also upload the template file directly to the OpenStack dashboard. however, and here is my question, many of the templates will also include shell scripts of powershell scripts which are run after deployment - how do we upload these scripts to OpenStack for inclusion in the stack?

for example, here is the directory listing for a MicroSoft SQL server template

C:\heat-templates\hot\Windows\MSSQLServer>ls
MSSQL.ps1  MSSQL.psm1  MSSQL.yaml  Tests  heat-powershell-utils.psm1

Heat client will only take the YAML file as an argument, so how or what do we do with the scripts?

thanks, Rob.


Solution

  • Refer to the heat's template guide: http://docs.openstack.org/developer/heat/template_guide/software_deployment.html

    Essentially resources defined in yaml template files can use "get_file" directive which reads strings from specified file name. So, when you invoke heat client your MSSQL.yaml, your heat client would parse it and wherever it sees "get_file" with a file name as an argument, it then reads from that file.

    Example using "get_file" from the above link:

    ...
    the_server:
      type: OS::Nova::Server
      properties:
        # flavor, image etc
        user_data:
          str_replace:
            template: {get_file: the_server_boot.sh}
            params:
              $FOO: {get_param: foo}