Vishnu,Here is a way to do test in puppet that works in all versions
of puppet I have tried it on
 if "|${var}|" != '||' {  # will be reached  unless $var is undef
or ''}
Here is an example testroot@dtkhost2:~# puppet
--version3.6.2###root@dtkhost2:~# cat /tmp/tt2.ppdefine test(  $var =
undef){  if "|${var}|" != '||' {    notice("var = ${var}")  } else
{   notice("var is undefined")  }}
test { a : }
test { b : var => 'set-val'}
###root@dtkhost2:~#  puppet apply /tmp/tt2.ppNotice: Scope(Test[a]):
var is undefinedNotice: Scope(Test[b]): var = set-val
--As far as your question with respect to having
class hadoop_configsfor globals; there are many ways to do this;
happy to work with you in finding best way- Rich

----- Original Message ----

.
From: Gajendran, Vishnu [mailto:[email protected] [1]]
Sent: Tuesday, December 30, 2014 12:34 PM
To: [email protected] [2]
Subject: adding new hadoop configurations in puppet templates

Hello all,

I am new to puppet scripts and my question is related to puppet
templates
and variables.

  I am working on adding some of missing hadoop configurations in
puppet
templates. For example, "hadoop.tmp.dir" config is missing in
core-site.xml
puppet template. So, to add these missing configs, I am using
extlookup("hadoop_tmp_dir", "") method to look for correponding config
value
if present in sitecsv file. So, if no key,value pair is present in
site.csv, the default value will be "". In the puppet templates, I can
check
for config != "" to confirm if there is a user specified value for the
config and write the configuration to the xml file.

I would like to use undef instead of emptry string ("") as default
value in
extlookup() method. But, I couldn't find a good way to check if
$variable !=
undef in puppet scripting.

I would like to know the bigtop devs opinion on this.

Also, I am planning to create a global class for holding all
configurable
hadoop settings like the one I mentioned above and refer those
variables in
the puppet templates like
scope.lookupvar('hadoop_configs::hadoop_config_tmp_dir') where
hadoop_configs is the global class which holds all the configuration
variables. Your opinion is greatly appreciated.

Thanks,
Vishnu
 

Links:
------
[1] mailto:[email protected]
[2] mailto:[email protected]

Reply via email to