Ask Your Question

Heat Template - Can we give hostname with comma separated from which instance should start with hostname which is specified

asked 2019-06-12 05:59:11 -0500

Srivalle gravatar image

I am creating cluster with 2 applications . First application will have 3 instances and second application i have to create 3 instances but i have to start the instance from name which i am giving as comma separated .

for eg , hostnames: type: string default: 'hostname-1,hostname-2'

The above servers will be creating with Resourcegroup and first instance hostname-0 i will be using logic call the script to install my application software. Basically this instance will have logic to install the application .

if we can have hostname as comma separated , how to read in the heat template . or is it possible or not .

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-06-20 09:05:25 -0500

zaneb gravatar image

Yes, this is possible (TripleO uses this trick), but I wouldn't recommend it.

First, you must define the scaled unit of your ResourceGroup to be a Heat template (rather than an OS::Nova::Server - the template will contain the server). The properties you pass to the scaled resource become the parameters to the template, so in addition to any parameters you want to pass through to the Server you also need to pass the list of hostnames and the index, which is represented by the string "%index%" (unless you change the index_var property). Then, inside the template you can get the right hostname from the list by doing {get_param: [hostnames, {get_param: index}]}.

However, IMHO the need to assign predetermined hostnames is overrated. Doing so means you have to manually manage the hostnames to always keep the list the same length as the size of the ResourceGroup, and skip any indices that have been blacklisted. It's easier to just define a hostname that includes %index% and have Heat automatically assign them. It's even better to not specify a name at all and let Heat choose one based on the name of the stack and the index. Finally, ResourceGroup itself is overrated, because it uses various suboptimal techniques when doing e.g. rolling updates purely for the purposes of fussily maintaining the contiguous list of indices. Personally, I would just use an AutoScalingGroup and accept the default randomly-generated hostnames.

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


Asked: 2019-06-12 05:59:11 -0500

Seen: 39 times

Last updated: Jun 20