novegin
novegin

Reputation: 11

how to use strings and parameters in openstack heat

I have defined a build parameter and i want to use that with a string in the resource but I am getting below error.

Error parsing template file:///update.yaml mapping values are not allowed in this context in "", line 14, column 46

heat_template_version: 2015-04-30
description: A base Server
parameters:
  build:
    type: string
    description: application build number
resources:
  server1:
    type: OS::Nova::Server
    properties:
      flavor: y6.tiny
      name: server1
      networks: [network: 45d06e78-3952-460e-bdba-1cf674621c3e]
      image: component-{ get_param: build }
      key_name: key
      security_groups:
        - DevOps-Sec

Upvotes: 1

Views: 1113

Answers (2)

depask
depask

Reputation: 93

I was looking for a similar configuration in my openstack heat configuration but for the "name" confing and I solved using the following:

name: 
    list_join: ['-', [ 'myfixedstring', { get_param: build } ]]

The '-' is the sequence used to join all the strings in the second parameter. I think this is a general approach for string manipulation in heat templates and so you can try to use for this specific case.

Further information: I am running a rocky compatible heat stack

heat_template_version: rocky

hope this will help someone else.

Upvotes: 0

hhoover
hhoover

Reputation: 649

Are you actually passing the parameter value? Try setting a default value for "build" in your template to a recent build number.

Upvotes: 0

Related Questions