array and string

233 views
Skip to first unread message

Hiu

unread,
Oct 29, 2012, 4:29:59 AM10/29/12
to puppet...@googlegroups.com
hi all,

I have an array and i would like to convert it into a string format.

e.g.

$server = ["node1", "node2", "node3"]

when I write my puppet codes

exec { "myscript -S $server":
path => XXXX
}

my $server becomes a continual string like: "node1node2node3", instead of "node1 node2 node3". How can i have a delimiter of space in between the array item?

thanks!

Johan De Wit

unread,
Oct 29, 2012, 5:08:43 AM10/29/12
to puppet...@googlegroups.com, Hiu
Hi,

you can use inline_template, this way you can incorperate ruby code in
your manifest

$server_string = inline_template("<% server.join(' ') %>")

see
http://docs.puppetlabs.com/references/latest/function.html#inlinetemplate

hope this helps

Grts

Jo
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/OdJUlKWcv9wJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.


--
Johan De Wit

Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________

Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________

Erik Dalén

unread,
Oct 29, 2012, 9:00:27 AM10/29/12
to puppet...@googlegroups.com
or use the join() function from puppetlabs-stdlib module.


--
Erik Dalén
> > To post to this group, send email to puppet...@googlegroups.com (mailto:puppet...@googlegroups.com).
> > To unsubscribe from this group, send email to
> > puppet-users...@googlegroups.com (mailto:puppet-users...@googlegroups.com).
> > For more options, visit this group at
> > http://groups.google.com/group/puppet-users?hl=en.
>
>
>
>
> --
> Johan De Wit
>
> Open Source Consultant
> Red Hat Certified Engineer (805008667232363)
> Puppet Certified Professional 2013 (PCP0000006)
> _________________________________________________________
>
> Open-Future Phone +32 (0)2/255 70 70
> Zavelstraat 72 Fax +32 (0)2/255 70 71
> 3071 KORTENBERG Mobile +32 (0)474/42 40 73
> BELGIUM http://www.open-future.be
> _________________________________________________________
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com (mailto:puppet...@googlegroups.com).
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com (mailto:puppet-users...@googlegroups.com).
Reply all
Reply to author
Forward
0 new messages