Ask Your Question
0

HEAT template for loop in a for loop

asked 2018-11-13 16:36:23 -0500

CloudUser99 gravatar image

updated 2018-11-13 16:37:10 -0500

I have data like: List1: A,B,C,D,E List2: 11,22,33,44,55

 repeat:
       for_each:
        <%list1indiv%>: {get_param: List1 }
       template:
        ip_prefix: <%list1indiv%>

I can do this for 1 loop. I want to have A=11 B=11 C=11 D=11 Basically looking a Loop like:

for (List1):
 for List2:
    template : Lis1 : list2.

How can I do loop in a loop please...

edit retag flag offensive close merge delete

Comments

I'm assuming you want A=11, B=22, C=33, D=44, E=55

zaneb gravatar imagezaneb ( 2018-11-19 11:24:13 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-19 11:23:11 -0500

zaneb gravatar image

Like this:

  repeat:
    template:
       key: value
    for_each:
      key: {get_param: List1}
      value: {get_param: List2}
    permutations: False

Note that this requires template version 2017-09-01 (added in the Pike release) or later.

An alternative is to use the yaql function:

  yaql:
    expression: dict($.data.keys.zip($.data.values))
    data:
      keys: {get_param: List1}
      values: {get_param: List2}

This requires template version 2016-10-14 (added in the Newton release) or later.

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-11-13 16:36:23 -0500

Seen: 263 times

Last updated: Nov 19 '18