QUESTION: How can I iterate through the whole list of facters in an erb template?

19 views
Skip to first unread message

Victor Martinez

unread,
Nov 10, 2016, 9:46:43 AM11/10/16
to Puppet Users
Hi there,

   I've been looking for a way of creating an erb file which contains all the facter values. Any ideas how I can accomplish it? Reason: I'd like to generate custom facters per module and populate those facter values as Jenkins Labels

Thanks so much

Matt Zagrabelny

unread,
Nov 10, 2016, 9:51:14 AM11/10/16
to puppet...@googlegroups.com
Untested:

<%
@facts.each do |key, value|
%->
<%= key %> and <%= value %>
<% end -%>

-m

Victor Martinez

unread,
Nov 14, 2016, 7:35:00 AM11/14/16
to Puppet Users
Cool, Thanks, finally I used another approach

 scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }.each do |k,v| -%>
<%= k %>-<%= v %>
<% end -%>


which it's basically based on:

Cheers
Reply all
Reply to author
Forward
0 new messages