Search code examples
yamlpuppeterbhiera

How do I process an yaml array in puppet ERB template?


I have some hiera data that looks like this:

netapp_nfs_shares:
  - 10.199.1.34:/os_cloud
  - 127.0.0.2:/example

This gets passed to my class as parameter and gets used in a erb template file that looks like this:

# This file was generated from nfs-shares.conf.erb by puppet
<% Array(@netapp_nfs_shares).each do |line| -%>
<%= line %>
<% end -%>

But when I puppet agent runs I get a file that looks like this:

# This file was generated from nfs-shares.conf.erb by puppet
["10.199.1.34:/os_cloud", "127.0.0.2:/example"]

I was hoping that I would get a file that looks like this:

# This file was generated from nfs-shares.conf.erb by puppet
10.199.1.34:/os_cloud
127.0.0.2:/example

I suspect that the template I wrote has something wrong with it. What am I doing wrong?


Solution

  • Something like this should do it:

    <% @netapp_nfs_shares.each do |line| -%>
    <%= line %>
    <% end -%>
    

    I suspect that by using Array() you are wrapping your array in another.