Ask Your Question
0

Use same resource in multiple yaml file with Heat

asked 2015-10-14 01:36:13 -0600

yaron gravatar image

I made a yaml file to define 3 networks,4 servers,1 router, 1 SecurityGroup. Each server use more than one network.

When all definition are in one single file, heat stack-create complete successfully.

I want to separate to multiple file to make it:
- more easy to read
- to be able to launch only specific instances

I though doing it with one yaml file for networks, one yaml file for each server, one yaml file for security group, and one yaml that launch everything together.

I started to put the Security group in a separate file but i got error:

PhysicalResourceNotFound: The Resource (arn:openstack:heat::2a86ebdb9b3f44e28716079ca27e9ac9:stacks/Company-SecurityGroup-o6f2oz2glxgh/ec742b1a-bbef-497c-a100-a5195e1bc839) could not be found.

SecurityGroup.yaml

heat_template_version: 2014-10-16

resources:
  server_security_group:
    type: OS::Neutron::SecurityGroup
    properties:
      name: server_security_group
      rules:
        - protocol: icmp
        - protocol: tcp
          port_range_min: 22
          port_range_max: 22
        - protocol: tcp
          port_range_min: 5433
          port_range_max: 5433
        - protocol: tcp
          port_range_min: 8080
          port_range_max: 8081
        - protocol: tcp
          port_range_min: 3030
          port_range_max: 3030

Launcher.yaml

heat_template_version: 2014-10-16

parameters:
  traffic_probe_port:
   type: string
   description: Fixed ip 
   default: 10.0.1.4

resources:

  SecurityGroup:
    type: SecurityGroup.yaml


   traffic_net:
     type: OS::Neutron::Net
     properties:
       name: TrafficNetwork

  traffic_net_subnet:
    type: OS::Neutron::Subnet
    properties:
    name: TrafficSubnet
    network_id: { get_resource: traffic_net }
    cidr: 10.0.1.0/24
    gateway_ip:
      allocation_pools:
        - start: 10.0.1.3
          end: 10.0.1.20


  traffic_net_port_vprobe:
    type: OS::Neutron::Port
    properties:
       network: { get_resource: traffic_net }
       fixed_ips:
          - ip_address: { get_param: traffic_probe_port }
     security_groups:
          - { get_resource: server_security_group }

   ....all network and server definitions

My goal is to do the Launcher file like the following. Is this possible?

heat_template_version: 2014-10-16

parameters:
  traffic_probe_port:
   type: string
   description: Fixed ip 
   default: 10.0.1.4

resources:

  SecurityGroup:
    type: SecurityGroup.yaml

 Networks:
   type: Networks.yaml

  Server1:
    type: Server1.yaml

  Server2:
    type: Server2.yaml

  Server3:
    type: Server3.yaml
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2016-04-25 08:21:45 -0600

TejasG gravatar image

Hello Zaneb,

I am trying to achieve the same.

To simplify I have heat template to create flavor. I am trying to follow the same thing what you have suggested above in your comment, but i am getting "recourse not found" error.

Would you throw out any example or link?

edit flag offensive delete link more
0

answered 2016-02-01 12:12:16 -0600

zaneb gravatar image

You can do this, but you can't (yet) do get_resource on your resource of type SecurityGroup.yaml and have it magically get the id of the resource inside.

In SecurityGroup.yaml you need to create an ouput that has the value { get_resource: server_security_group }, and then in your Launcher file use {get_attr: [SecurityGroup, <name of the output>]} to get the uuid of the security group to pass to other resources.

edit flag offensive delete link more
0

answered 2015-12-06 03:41:24 -0600

Jeffrey Guan gravatar image

yes,it is possible

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: 2015-10-14 01:36:13 -0600

Seen: 1,156 times

Last updated: Feb 01 '16