Ask Your Question

escaping erb parameters

asked 2015-07-01 14:36:28 -0600

Yalu gravatar image


when passing a parameter (an LDAP serach filter) to ERB template this does not translate as expected.

My parameter (from hiera yaml) I expect to be literally translated:

appregaaa::radldapprops: filter: '(&(uid=%{User-Name})(o:dn:=%{Realm}))'

The erb template section:

filter = "<%= @radldap_props['filter'] %>"

The result:

filter = "(&(uid=)(o:dn:=))"

I guess both %{User-Name} and %{Realm} get reinterpreted, but I can't seem to figure out how to prevent this and apply the correct escaping. Any help greatly appreciated.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-07-05 21:37:52 -0600

updated 2015-07-05 22:19:30 -0600

The variables used in ERB templates should come from your manifests, not directly from hiera.

You need something like:


app_regaaa::radldap_props::filter: '...<your_filter>...'


class app_regaaa::radldap_props (
) {

ERB template:

filter = "<%= @filter %>"

Note that you may have trouble escaping the % sign in your hiera data, have a look at e.g. this jira ticket

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-07-01 14:36:28 -0600

Seen: 80 times

Last updated: Jul 05 '15