hashes not hashes ?

18 views
Skip to first unread message

Fabrice Bacchella

unread,
Sep 3, 2014, 5:31:11 AM9/3/14
to puppet...@googlegroups.com
I'm trying to send an hash to a template.

I'm calling a type with :

supervisord::program{'hadoop.namenode':
...
environment => {
JAVA_HOME => "$javahome",
HADOOP_HOME => "/data/hadoop/distrib",
HADOOP_CONF_DIR => "/data/hadoop/config",
HADOOP_LOG_DIR => "/data/hadoop/logs",
JAVA_LIBRARY_PATH => "/data/hadoop/native",
},
}

supervisord::program call a template that includes :

environment = <% @environment.each do |name, value|%><%=name%>="<%=value%>",<% end %>

but what I get is:
environment = Hadoop_log_dir[]="/data/hadoop/logs",Hadoop_conf_dir[]="/data/hadoop/config",Java_home[]="/usr/java/latest",Hadoop_home[]="/data/hadoop/distrib",Java_library_path[]="/data/hadoop/native",

If is use:
environment => {
"JAVA_HOME" => "$javahome",
"HADOOP_HOME" => "/data/hadoop/distrib",
"HADOOP_CONF_DIR" => "/data/hadoop/config",
"HADOOP_LOG_DIR" => "/data/hadoop/logs",
"JAVA_LIBRARY_PATH" => "/data/hadoop/native",
},

I get:
environment = HADOOP_CONF_DIR="/data/hadoop/config", HADOOP_HOME="/data/hadoop/distrib", HADOOP_LOG_DIR="/data/hadoop/logs", JAVA_HOME="/usr/java/latest", JAVA_LIBRARY_PATH="/data/hadoop/native",

It works. What's wrong with the first version ?

My puppet version is 3.6.2

jcbollinger

unread,
Sep 3, 2014, 2:02:03 PM9/3/14
to puppet...@googlegroups.com
For bare words to be interpreted as strings, they must begin with a lowercase letter.  There are other restrictions, too.  Yes, it's a bit weird -- in fact, I wasn't mindful of the initial letter rule in this context until I looked into this matter, though I am well aware of the flip side, that resource references must begin with capital letters.

Bottom line: it's good practice to quote your strings.


John

Fabrice Bacchella

unread,
Sep 3, 2014, 3:44:21 PM9/3/14
to puppet...@googlegroups.com

Le 3 sept. 2014 à 20:02, jcbollinger <John.Bo...@stJude.org> a écrit :


For bare words to be interpreted as strings, they must begin with a lowercase letter.  There are other restrictions, too.  Yes, it's a bit weird -- in fact, I wasn't mindful of the initial letter rule in this context until I looked into this matter, though I am well aware of the flip side, that resource references must begin with capital letters.


I can live with what. I just wanted to know what was wrong. Thanks

Reply all
Reply to author
Forward
0 new messages