Ask Your Question
1

echo a variable and for loop

asked 2018-11-08 14:37:08 -0600

CloudUser99 gravatar image

updated 2018-11-08 14:44:21 -0600

Is there a way I can echo a variable in the HEAT template on the console?

2) how does for_eack works? can we assign a file output to the loop which is comma_separated?

foreach:
   x: {get_param: {get_file:text.txt}}
template:
    ...
 assigned

I am not able to get the comma_separated data assigned to x

edit retag flag offensive close merge delete

Comments

get_param expects the name of a parameter after the colon, not a comma-separated list. To assign a comma-separated list, or any other value, to a parameter from a file, use an environment file.

Bernd Bausch gravatar imageBernd Bausch ( 2018-11-09 00:48:13 -0600 )edit

Thank you Bernd. Can you please give me a example (or) link with using a environment file and reading a array from it. I searched could not find one

CloudUser99 gravatar imageCloudUser99 ( 2018-11-09 06:57:57 -0600 )edit

I have never done this, but assuming the parameter is named my_param, it's probably something like this:

parameters:
   my_param: "item1,item2,item3"

Put this in a file, then launch the stack with option -e FILENAME.

In the template, you can use my_param in a foreach clause.

Bernd Bausch gravatar imageBernd Bausch ( 2018-11-09 07:48:34 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-11-09 12:12:39 -0600

zaneb gravatar image

You can define outputs from a template whose values can calculated using intrinsic functions and data from the stack. These values are then accessible from the CLI.

We also have docs for the repeat function.

In your example, you appear to be trying to get from a file the name of the parameter containing the list of values you want to iterate over? I think that works, but it's unusual enough that I suspect you wanted to do something different. I can't tell what though.

edit flag offensive delete link more

Comments

Can you please give any example so that I can loop over the variables . I tried repeat also not able to do that .

CloudUser99 gravatar imageCloudUser99 ( 2018-11-13 16:02:13 -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: 2018-11-08 14:37:08 -0600

Seen: 38 times

Last updated: Nov 09