hiera and variable hash array

49 views
Skip to first unread message

Luca Gervasi

unread,
Mar 15, 2015, 6:16:08 AM3/15/15
to puppet...@googlegroups.com
Hello,

i'm trying to achieve aconfiguration where i can applt a  non predetermined list of hashes. Specifically, i'm willing to add to php.ini (or fpm...) specific flags.

This is my hiera data:

fpm::pools::web::adminvalues:
 - error_log: /var/log/fpm/$pool/php.log
 - memory_limit: 32M
fpm::pools::web::adminflags:
 - display_errors: off
 - log_errors: on

fpm::pools::web::adminvalues and fpm::pools::web::adminflags's hashes is variable, so I have 2 entries in this example, but i should be able to iterate and apply whichever settings is configured. (this means that i cannot refer to them like $adminvalues['error_log']).

This is a snippet of the ruby code I used to extract the codes (which is ineffective):

[this is a local manifest variable, $name is "web" (so the hiera lookup is not the problem here)]
$pooladminflags = hiera_array("fpm::pools::${name}::adminflags", "")
$pooladminvals = hiera_array("fpm::pools::${name}::adminvalues", "")

[this is in the template i use]
<%
scope.lookupvar('pooladminflags').each do |key| -%>
php_admin_flag[<%=key[0]%>] = <%=key[1]%>
<% end-%>

Needless to say, it is empty. What am I missing?

Thanks a lot.

Patrick Robinson

unread,
Mar 18, 2015, 8:17:01 AM3/18/15
to puppet...@googlegroups.com
The ruby call you're looking for is each_pair used like this:

<% scope.lookupvar('hash').each_pair do |key,value| -%>
<%= key %> = <%= value %>
<% end -%>
Reply all
Reply to author
Forward
0 new messages