Ask Your Question
0

Nested stacks and parameter names and defaults

asked 2016-10-11 15:14:25 -0600

woodside gravatar image

updated 2016-11-15 09:13:39 -0600

zaneb gravatar image

Hi,

I have declared similar 2 nested resources in one single stack as given below:

obj1:
    type: OS::Nova::MyServer

obj2:
    type: OS::Nova::MyServer

I have also declared a default parameter in a .env file, which is used while creating the above heat stack:

parameter_defaults:
  stack_name: stack1

which is used internally within MyServer, which is a nested resource, many levels deep. Now, I want to be able to pass a different stack_name for each of obj1 and obj2, which would get passed to the very last level, without changing all the resource levels to include "stack_name" as a parameter input. So, in short, I want it to be a default parameter, but defined in the top level heat yaml file, not in the env file, so that I can give a different name to each object, and not pass it at every level - is there a way to do that?

Another related question: when I use OS::stack_name, internally within the nested stacks, but it changes the stack_name which was given in heat stack-create to the name+random_string -- is there a way to retain the original heat stack name in the internal nested templates?

Thanks
Anjali

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-11-15 09:23:13 -0600

zaneb gravatar image

All stacks in a tree of nested stacks get the same environment, so there's no way to specify different parameter defaults for each of them.

OS::stack_name in a nested stack will give the name of the nested stack, not the name of the root stack. Nested stacks can't have the same name as the root stack because stack names must be unique.

edit flag offensive delete link more

Comments

Just found http://docs.openstack.org/developer/heat/template_guide/environment.html

Seems that there is a difference between parameters: section and parameters_defaults: section. And then there is the merge_strategies ...

frippe75 gravatar imagefrippe75 ( 2016-12-29 16:53:58 -0600 )edit

Realizes after reading the env html a few times that my question is not really related to the orginal. But defining my key_name under parameter_defaults made it available in nested yaml files as well. So for parameters: you really need to keep passing then explicitly.

frippe75 gravatar imagefrippe75 ( 2016-12-29 17:02:48 -0600 )edit
-1

answered 2016-12-29 15:57:48 -0600

frippe75 gravatar image

Not sure If I'm out of my depths here. But was that the answer to the question? I'm facing a problem where I think I have the same issue as the original question.

I pass a env file to "openstack stack create ...." The env contains among other parameters the parameter key_name=mykey2.

So my first level yaml file look like:

parameters:
  key_name:
    type: string

resources:
  my_instance:
    type: single_server.yaml
    properties:
      # key_name: {get_param: key_name}   ## Not passing the key_name here

I.e key_name gets passed down to to single_server.yaml

parameters:
  key_name:
    type: string
    default: mykey

resources:
  server:
type: OS::Nova::Server
properties:

    properties:
      key_name: {get_param: key_name}

Error is that mykey is missing. Using a different openstack setup where mykey is not uploaded. I was under the impression parameters had to be passed explicitly down the tree. If this is the case my templates tends to get quite repetetive. Would be nice to have an option to pass all env down with an option.

May a different question all together?

edit flag offensive delete link more

Comments

parameter_defaults does what you want here - passes the same default values to all nested templates. The question was about passing different values to different nested templates.

zaneb gravatar imagezaneb ( 2017-01-02 08:25:07 -0600 )edit

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-10-11 15:14:25 -0600

Seen: 455 times

Last updated: Dec 29 '16