Ask Your Question
0

Parameter input in nested heat templates

asked 2016-07-15 14:33:23 -0500

bitskrieg gravatar image

I am currently in the process of building out nested heat templates where the master template defines some globally-applicable parameters and then just calls other templates as resources as required:

heat_template_version: 2015-10-15

description: Generic OpenStack Deployment Script

parameters:

  base_string:
    type: string
    label: Base String
    description: The unique string which will form the base of all initial resource names in your deployed environment
    default: changeme
      constraints:
        -  length: { min: 3, max: 10 }
      description: Base name must be between 3 and 10 characters
        -  allowed_pattern: "[a-z]*"
      description: Base name must contain only lower case letters

        ...
      resources:    
          network:
            type: https://bitbucket.org/xxx/xxx/raw/master/heat/network/private.yaml
            properties:
              base_string: { get_param: base_string }

        debian:
          type: https://bitbucket.org/xxx/xxx/raw/master/heat/os/debian.yaml
          depends_on: network
          properties:
            base_string: { get_param: base_string }
            network: { get_attr: [network, name] }

etc. My resource templates look like this:

heat_template_version: 2015-10-15

description: Private Network Deployment Heat Template

parameters:

  base_string:
    type: string
    label: Base String
    description: The unique string which will form the base of all initial resource names in your deployed environment
    default: changeme
    constraints:
      -  length: { min: 3, max: 10 }
         description: Base name must be between 3 and 10 characters
      -  allowed_pattern: "[a-z]*"
         description: Base name must contain only lower case letters

  network_ID:
    type: number
    label: Choose a number between 0 and 255
    description: This will determine your exact network subnet for your deployment
    default: 0
    constraints:
      -  range: { min: 0, max: 255 }

resources:

  random-str:
    type: OS::Heat::RandomString
    properties:
      length: 3  

  network:
    type: OS::Neutron::Net
    properties:
      name:
        str_replace:
          template: base_rand_network
          params:
            base: { get_param: base_string }
            rand: { get_resource: random-str }
...

As it stands right now, if I call the master template in horizon, it won't ask for parameter input for parameters that exist only in the sub-templates (such as network_ID in the above example), only the ones that are explicitly defined in the master. I could just go and declare all parameters across all templates in the master, but that is inelegant and kind of defeats the purpose of the modularity I am trying to achieve.

Is what I am asking for possible, or does this functionality not exist yet?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-07-28 07:54:34 -0500

zaneb gravatar image

updated 2016-07-28 07:56:01 -0500

The idea is that you declare all of the parameters in the master template and explicitly pass them down to its children.

However, there is also a template_defaults section in the environment file that allows you to override default values in _any_ template in the tree. (Any explicitly-passed values will in turn override these defaults.) TripleO makes extensive use of this mechanism to keep parameter values for child templates away from the main stack's parameters section. However, I don't know that Horizon has support for environment files so you may have to do this via the command line.

edit flag offensive delete link more

Comments

I thought this might be the case. Oh well, perhaps in a future version it will be able to pull in parameters from child templates.

Thanks for taking the time to answer!

bitskrieg gravatar imagebitskrieg ( 2016-07-30 15:40:55 -0500 )edit
-1

answered 2017-02-16 08:06:22 -0500

udayutkarsh gravatar image

I am getting error from master file about one of the parameter in chile file.

child.yaml:

heat_template_version: 2016-04-08 description: this is test file to demonstrate nesting templates

parameters: vm-name: type: string default: ud-test-vm

resources: instance: type: OS::Nova::Server properties: name: { get_param: vm-name } flavor: m1.svc networks: - network: enm_internal_network_megha key_name: enm_keypair image: cirros

parent.yaml::

heat_template_version: 2015-04-30 description: this demo master file

parameters: vm-name-master: type: string default: vm-name-calling

resources: instance-calling: #type: file:///home/uday/ENM/template/child.yaml type: ./child.yaml properties: vm-name = { get_param: vm-name-master }

Error:: ERROR: Property error: : resources.instance-calling.properties: : Unknown Property vm-name = { get_param

Any help??

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-07-15 14:33:23 -0500

Seen: 2,063 times

Last updated: Feb 16 '17