hash lookup in template using scope function

asked 2016-07-25 09:39:23 -0500

rajeevsharma gravatar image

updated 2016-07-25 09:40:23 -0500

Hi, I want am using following code for hiera lookup which is working fine.

YAML
---
appname: 'tomcat'

Template
---
appname: <%= scope().call_function('hiera',['appname'])%>

But, now I have values in YAML in hash format and I want to do lookup using $hostname.appname (where hostname should be facter and appname is sub key) e.g.

YAML
---
agentnode1:
   appname: 'tomcat'
   approle: 'webserver'

Template
---
approle: <%= scope().call_function('hiera',['@hostname.approle'])%>

Above lookup is not working as @hostname facter is not getting resolved in this lookup. Also, I tried escaping the quotes but no use. Any ideas?

edit retag flag offensive close merge delete