Hi Arun, On Feb 8, 2017 7:32 AM, "Arun Kumar" <r.arunkumar...@gmail.com> wrote:
Hi Henrik, I have a requirement where i need to interpolate facter and an array element. Facters are interpolated in double quotes and array elements inside it is getting treated as a one single string. So could you advise on this? $dir=["/share","/share/dir1"] mount { /opt/share1 : device => "$::fqdn:/$dir[1]", options => defaults, fstype => nfs, ensure => mounted, } For accessing an array element, you'll need to use the expression form of an interpolation: "...${dir[1]}..." There is no need to use a dollar sign on the variable inside the brackets because array accesses are treated specially. Outcome: tail -1 /etc/fstab client.example.com://share/share/dir1[1] /opt/share1 nfs defaults 0 0 Expected: tail -1 /etc/fstab client.example.com:/share/dir1[1] /opt/share1 nfs defaults 0 0 Did you mean to have [1] in the expected output here? If so, include it after the closing brace of the expression above. On Sunday, 22 January 2017 22:35:51 UTC+5:30, Arun Kumar wrote: > > Hi Guys, > > I am very new to Puppet and installed 3.8. I tried creating template using > array type variable but I got output as string. > > My sample code as below: > > init.pp > ------- > $servers = ['facter', 'hiera', 'mco', 'puppet', 'puppetserver'], > > config.pp > ---------------------- > $servers = "$::apache::servers", > > file {"/root/welcome": > ensure => present, > content => template('apache/hello.erb'), > > > hello.erb > ------------------ > <% @servers.each do |val| -%> > Welcome <%= val %> > <% end -%> > > > output as : > ========== > > cat /root/welcome > Welcome facterhieramcopuppetpuppetserver > > Any help will be appreciated. > > Thanks, > Arun > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/ msgid/puppet-users/6608f6b1-d791-4b1a-ac87-fa4f19abc6cd%40googlegroups.com <https://groups.google.com/d/msgid/puppet-users/6608f6b1-d791-4b1a-ac87-fa4f19abc6cd%40googlegroups.com?utm_medium=email&utm_source=footer> . For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CACZQQfOe1TnpfXRhCLEe1a%2BgunwKGRtt4eD384_y3tACJBcBPA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.