I am trying to create a cluster using Heat Templates of Openstack. I have following template defining my resource group.
cluster:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: instance_count }
resource_def:
type: ../templates/vm.yaml
properties:
image: { get_param: image }
flavor: { get_param: flavor }
private_network : { get_attr : [network, name] }
This works, but the name of all these servers is very cryptic. I was wondering if it would be possible to provide a prefix to name to each of the instances.
Or another way could be is I can str_replace
a template value with the current index of the cluster count.
Is there a way to achieve this?
Nevermind, got it from the ResourceGroup documentation. Use %index%
.
Here is the example from the documentation.
resources:
my_indexed_group:
type: OS::Heat::ResourceGroup
properties:
count: 3
resource_def:
type: OS::Nova::Server
properties:
# create a unique name for each server
# using its index in the group
name: my_server_%index%
image: CentOS 6.5
flavor: 4GB Performance