Use external facts inside templetes

35 views
Skip to first unread message

Malintha Adikari

unread,
Jun 17, 2014, 7:33:06 AM6/17/14
to puppet...@googlegroups.com

I have defined some key value pairs in /etc/facter/facts.d/value.txt file. I could use those keys inside my init.pp script and successfully for the values using

   ${key1}
 

I want to get those values inside my template file. I have used

   <%= @key1 %>
 

but it doesn't give me the value. What is the correct way to get the value of the external fact inside template.

Regards,

Malintha

Sans

unread,
Jun 17, 2014, 8:28:29 AM6/17/14
to puppet...@googlegroups.com
Hi there,

First of all, if it's a fact, then you really should be doing ${::key1} instead.

To use it in template, <%= @key1 %> should work just fine.  Otherwise, you can have this: $localkey = ${::key1} in your init.pp and then <%= @localkey %> in the template but I don't think you gonna get anything thing better.

On the agent, if you do: facter -p key1, do you get the result that you expect? Best!

Malintha Adikari

unread,
Jun 18, 2014, 12:47:31 AM6/18/14
to puppet...@googlegroups.com
Hi Sans,

My issue was solved. My actual key name was "portOffset". Note about the camel case. (there is a capital 'O'). What I did was changed it to just "portoffset" and works fine. Is this a issue ?

Regards,
Malintha Adikari
Reply all
Reply to author
Forward
0 new messages