On Thursday, September 4, 2014 11:27:31 PM UTC-5, Colin Kincaid Williams
wrote:
>
> I have a hacked together class that somebody else wrote based on some
> wikimedia puppet scripts. I've been asked to set the JAVA_HEAP_MAX if the
> host is a resource manager.
>
> I'm trying to set the variable yarn_env_java_heap_max if the host is a rm.
> Is it possible to set the paramater as below? Do I have to create a
> separate role just to set this paramater? Am I better off checking if a rm
> in the yarn-site.sh.erb template itself?
>
> if ($::hostname in $rm_hosts){
> yarn_env_java_heap_max => '-Xmx4000M',
> }
>
>
That looks like it's meant to be resource- or class-parameter binding (use
of '=>' but not '$'), but I'm having trouble spotting where it should (or
does) go in your lengthy code. Supposing that it is indeed a parameter
binding, you cannot use an 'if' statement, but you can use a selector
expression
<https://docs.puppetlabs.com/puppet/3/reference/lang_conditional.html#selectors>
:
$is_rm = $::hostname in $rm_hosts
my_module::my_resource_type { 'rm':
yarn_env_java_heap_max => $is_rm ? { true => '-Xmx4000M', default =>
undef }
}
If you do after all mean to set a variable in the local scope then you can
use an 'if' statement, but these may not appear inside resource parameter
lists:
if $::hostname in $rm_hosts {
$yarn_env_java_heap_max = '-Xmx4000M'
}
I am accsessing the variable in the yarn-site.sh.erb template as follows:
>
> <% if @yarn_env_java_heap_max -%>
> JAVA_HEAP_MAX = <%= yarn_env_java_heap_max %>
> <% end -%>
>
>
You really should use the '@' sigil consistently. Although variables
@yarn_env_java_heap_max and yarn_env_java_heap_max *probably* have the same
value when that template code is evaluated, they are separate variables,
and under certain circumstances they might have different values.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/e0ce42e3-bc3d-43d4-bd43-673d47868a95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.