How to print Array with quotation marks in epp?

760 Views Asked by At

Given the hiera list (example values):

simplekey:
  hosts:
    - 'host1:8080'
    - 'host2:8080'
  [...]

When using ERB template, this code:

<% @simplekey.sort.each do |key, value| -%>
  <%= key %>: <%= value %>,
<% end -%>

results in

  hosts: ["host1:8080", "host2:8080"],

When migrating the code to EPP, a similar code:

<% $simplekey.each |$key, $value| { -%>
  <%= $key %>: <%= $value %>,
<% } -%>

results in (notice the missing quotation marks):

  hosts: [host1:8080, host2:8080],

Is there any way I can print the hosts array with quotation marks?

Puppet version: 6.23.0

1

There are 1 best solutions below

2
On

Super simple - just put the quotes in the EPP:

<% $simplekey.each |$key, $value| { -%>
  "<%= $key %>": <%= $value %>,
<% } -%>