Ask Your Question
0

escaping erb parameters

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

Yalu gravatar image

Hi,

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.

Tx

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

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

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

You need something like:

Hiera:

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

Manifest:

class app_regaaa::radldap_props (
  $filter,
) {
  validate_string($filter)
  ...

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

Stats

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

Seen: 72 times

Last updated: Jul 05 '15