Openstack Heat - separate templates

回眸只為那壹抹淺笑 提交于 2019-12-08 12:38:48

问题


I am looking for the best way of creating a stack, in a number of separate steps.

I would like in the first template, to only get up the compute nodes and the network configuration.

In the second template, I would like to create the storage nodes and attach them to the already existing compute nodes.

What do you think is the best way to do this?


回答1:


Following is one possible approach.

1) Define first template for your compute nodes and network configuration. But define outputs in your first template to expose your compute node IDs. For example, if you create a OS::Nova::Server with name mynode1, you can expose its ID as the output for that template as follows:

outputs:
  mynode1_id:
    description: ID of mynode1
    value: {getattr: [mynode1, id]}

Once you instantiate a heat stack, say mystack1, with this first template, then you can access the ID of mynode1 as follows:

heat output-show mystack1 mynode1_id

2) Create your second template for storage with IDs of your compute nodes from step1 as input parameters. For example:

parameters:
  mynode1_id:
    type: string
    description: ID for mynode1

Then you can use that in your "resources:" section as follows:

resources:
  ...
  ...
  my_volume_attach:
    type: OS::Cinder::VolumeAttachment
    properties:
      instance_uuid: {get_param: mynode1_id}
      ...

3) Invoke your second heat stack creation as follows:

heat stack-create -f second-template.yaml -P mynode1_id=`heat output-show mystack1 mynode1_id` mystack2



回答2:


You might also want to define dependencies between your resources, using the depends_on attribute. From your description it doesn't seem like using several templates is the correct solution.

for example - if you want objects 3,4 created after objects 1,2, you can define a template as follows:

heat_template_version: '2015-10-15'
parameters:
   param1:
        type: string
        description: just an example of parameter
resources:
 object1:
  type: OS::Neutron::XXX
  properties:
     property: XXX
  description: object1
 object2:
  type: OS::Neutron::XXX
  properties:
     property: XXX
  description: object2
 object3:
  type: OS::Nova::XXX
  properties:
     property: XXX
  description: object3
  depends_on: object1
 object4:
  type: OS::Nova::XXX
  properties:
     property: XXX
  description: object4
  depends_on: object1


来源:https://stackoverflow.com/questions/37089728/openstack-heat-separate-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!