Ask Your Question
0

heat template for Mitaka release with a loop

asked 2018-09-06 08:31:49 -0500

BiG_NoBoDy gravatar image

updated 2018-09-06 08:33:18 -0500

Hi team,

My heat template looks like this:

---
description: "blah
blah"
heat_template_version: 2016-04-08
parameters:
  flavor_name:
    default: SMALL
    type: string
  image_id:
    default: centos
    type: string
  public_net:
    default: d8772e7a-07b1-4273-beb6-860fb54e54c1
    type: string
  subnetwork:
    default: b4cb500a-aa47-4f74-8fe4-d68ddc94c94b
    type: string
  secgroup_id:
    default: default
    type: string
resources:
  server1:
    properties:
      flavor:
        get_param: flavor_name
      image:
        get_param: image_id
      name: Server1
      networks:
        - 
          port:
            get_resource: port1x10
    type: "OS::Nova::Server"
  port1:
    properties:
      name: port1
      fixed_ips:
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
        - subnet_id: { get_param: subnetwork }
      network_id:
        get_param: public_net
      security_groups:
        - 
          get_param: secgroup_id
    type: "OS::Neutron::Port"

My "mission" to remove repeating lines: "- subnet_id: { get_param: subnetwork }"

I was looking at count: 180 but count is not recognised in here... I found

repeat:
  for_each:
    var: list
  template:
    - subnet_id: { get_param: subnetwork }

But how to make this list so I could add like 180 or 110 and 70 IP's to the port... ? Any ideas?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2018-09-17 16:17:25 -0500

zaneb gravatar image

updated 2018-09-17 16:19:45 -0500

Starting with Newton you could use something like:

yaql:
    expression: "[$.data.subnet_defn] * $.data.count"
    data:
        subnet_defn:
            subnet_id: {get_param: subnet_id}
        count: 9

but there is no yaql function in Mitaka. I don't believe there's a way to do what you want in a release that old.

edit flag offensive delete link more
-1

answered 2018-09-10 01:22:08 -0500

novainfinite gravatar image

try to remove name: Server1 it is mistake in server or server 1

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: 2018-09-06 08:31:49 -0500

Seen: 34 times

Last updated: Sep 17