Support Questions
Find answers, ask questions, and share your expertise

[Cloudbreak] Variables in Ambari Blueprint

[Cloudbreak] Variables in Ambari Blueprint

I've seen two types of variables used generally in Ambari blueprints:

1. %HOSTGROUP%

2. {{ var }}

%HOSTGROUP% according documentation should resolve into respective nodes domain/IP, but it does not happen. Is there a way to troubleshoot this (I've grepped ambari logs files with no success)?

Following thread implies that out-of-stack services are not getting replaced: https://community.hortonworks.com/questions/74729/ambari-does-not-resolve-hostgroup-into-hostnames-a...

Is that still stands true?

Regarding second type, they are replaced with emptiness, so when I set following:

export HADOOP_HOME=${HADOOP_HOME:-{{hadoop_home}}}

It gets replaced with:

export HADOOP_HOME=${HADOOP_HOME:-}

Or: JAVA_HOME={{java_home}} With: JAVA_HOME=

I tried to replace {{ with \\{{, but blueprint editor does not allow these symbols.

I was not able to find any description of both variable types and how to properly use them. Can someone help figure this out?

1 REPLY 1
Highlighted

Re: [Cloudbreak] Variables in Ambari Blueprint

Rising Star

Hi @Dima Kovalyov,

The "HOSTGROUP" token syntax is not a general-purpose mechanism for resolving hostnames in the configuration for a Blueprint.

This syntax is generally used in the following scenarios:

1. Exported Blueprints

2. HA-related Blueprints

Outside of these scenarios, the "HOSTGROUP" syntax is not recommended.

The Ambari Blueprints configuration processor will attempt to match HOSTGROUP tokens with hostnames for a specific subset of configuration properties, but this subset of properties is a static list, and is not configurable.

As you mentioned, it is also true that out-of-stack services are not supported by this syntax, for the reason I've listed above.

The "{{ var }}" syntax is not directly supported by the Blueprints processor. There might be cases where a configuration property is pushed down to an ambari-agent that interprets this python-like variable, but this behavior is not guaranteed to work, and should be avoided in Blueprints.

Hope this helps.

Thanks,

Bob