FAQ
Hello guys,

I would like to get some help with puppet about using an array in a
template.

I've a custom facts that return me this:

tsm_vmp / /home /tmp /var/tmp /usr /var

I have a class that use this facts to split it on every space and to a
an entry in a template for each value, here is the code I use for
this:

$virtualmountpoints = split($tsm_vmp, ' ')
...
"/opt/tivoli/tsm/client/ba/bin/dsm.sys":
owner => root,
group => root,
mode => 0600,
content => template("tsm/dsm.sys.erb"),

That's what's I have in my template

<% virtualmountpoints.each do |fs| -%>
virtualmountpoint <%= fs %>
<% end -%>



Thats what I get:
virtualmountpoint /
/home
/tmp
/var/tmp
/usr
/var

but I would like to get instead:
virtualmountpoint /
virtualmountpoint /home
virtualmountpoint /tmp
virtualmountpoint /var/tmp
virtualmountpoint /usr
virtualmountpoint /var


Do you know how to do this?

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

Search Discussions

  • Luke Bigum at Apr 24, 2012 at 8:55 am
    Very close:

    <% virtualmountpoints.each do |fs| -%>
    [<%= fs %>]
    virtualmountpoint<%= fs %>
    <% end -%>

    I don't understand the Ruby in that, I copied it from someone else ;-)
    On 24/04/12 09:18, digrouz wrote:
    Hello guys,

    I would like to get some help with puppet about using an array in a
    template.

    I've a custom facts that return me this:

    tsm_vmp / /home /tmp /var/tmp /usr /var

    I have a class that use this facts to split it on every space and to a
    an entry in a template for each value, here is the code I use for
    this:

    $virtualmountpoints = split($tsm_vmp, ' ')
    ...
    "/opt/tivoli/tsm/client/ba/bin/dsm.sys":
    owner => root,
    group => root,
    mode => 0600,
    content => template("tsm/dsm.sys.erb"),

    That's what's I have in my template

    <% virtualmountpoints.each do |fs| -%>
    virtualmountpoint<%= fs %>
    <% end -%>



    Thats what I get:
    virtualmountpoint /
    /home
    /tmp
    /var/tmp
    /usr
    /var

    but I would like to get instead:
    virtualmountpoint /
    virtualmountpoint /home
    virtualmountpoint /tmp
    virtualmountpoint /var/tmp
    virtualmountpoint /usr
    virtualmountpoint /var


    Do you know how to do this?

    --
    Luke Bigum

    Information Systems
    Ph: +44 (0) 20 3192 2520
    luke.bigum@lmax.com | http://www.lmax.com
    LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN


    FX and CFDs are leveraged products that can result in losses exceeding
    your deposit. They are not suitable for everyone so please ensure you
    fully understand the risks involved. The information in this email is not
    directed at residents of the United States of America or any other
    jurisdiction where trading in CFDs and/or FX is restricted or prohibited
    by local laws or regulations.

    The information in this email and any attachment is confidential and is
    intended only for the named recipient(s). The email may not be disclosed
    or used by any person other than the addressee, nor may it be copied in
    any way. If you are not the intended recipient please notify the sender
    immediately and delete any copies of this message. Any unauthorised
    copying, disclosure or distribution of the material in this e-mail is
    strictly forbidden.

    LMAX operates a multilateral trading facility. Authorised and regulated
    by the Financial Services Authority (firm registration number 509778) and
    is registered in England and Wales (number 06505809).
    Our registered address is Yellow Building, 1A Nicholas Road, London, W11
    4AN.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Nicolas Di Gregorio at Apr 24, 2012 at 9:51 am
    I just found my problem,

    It is in the split in fact I don't have space between the value but carried
    returns, so if I split to "\n", it works.

    Regards
    On Tue, Apr 24, 2012 at 10:55 AM, Luke Bigum wrote:

    Very close:


    <% virtualmountpoints.each do |fs| -%>
    [<%= fs %>]

    virtualmountpoint<%= fs %>
    <% end -%>

    I don't understand the Ruby in that, I copied it from someone else ;-)

    On 24/04/12 09:18, digrouz wrote:

    Hello guys,

    I would like to get some help with puppet about using an array in a
    template.

    I've a custom facts that return me this:

    tsm_vmp / /home /tmp /var/tmp /usr /var

    I have a class that use this facts to split it on every space and to a
    an entry in a template for each value, here is the code I use for
    this:

    $virtualmountpoints = split($tsm_vmp, ' ')
    ...
    "/opt/tivoli/tsm/client/ba/**bin/dsm.sys":
    owner => root,
    group => root,
    mode => 0600,
    content => template("tsm/dsm.sys.erb"),

    That's what's I have in my template

    <% virtualmountpoints.each do |fs| -%>
    virtualmountpoint<%= fs %>
    <% end -%>



    Thats what I get:
    virtualmountpoint /
    /home
    /tmp
    /var/tmp
    /usr
    /var

    but I would like to get instead:
    virtualmountpoint /
    virtualmountpoint /home
    virtualmountpoint /tmp
    virtualmountpoint /var/tmp
    virtualmountpoint /usr
    virtualmountpoint /var


    Do you know how to do this?
    --
    Luke Bigum

    Information Systems
    Ph: +44 (0) 20 3192 2520
    luke.bigum@lmax.com | http://www.lmax.com
    LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN


    FX and CFDs are leveraged products that can result in losses exceeding
    your deposit. They are not suitable for everyone so please ensure you
    fully understand the risks involved. The information in this email is not
    directed at residents of the United States of America or any other
    jurisdiction where trading in CFDs and/or FX is restricted or prohibited
    by local laws or regulations.

    The information in this email and any attachment is confidential and is
    intended only for the named recipient(s). The email may not be disclosed
    or used by any person other than the addressee, nor may it be copied in
    any way. If you are not the intended recipient please notify the sender
    immediately and delete any copies of this message. Any unauthorised
    copying, disclosure or distribution of the material in this e-mail is
    strictly forbidden.

    LMAX operates a multilateral trading facility. Authorised and regulated
    by the Financial Services Authority (firm registration number 509778) and
    is registered in England and Wales (number 06505809). Our registered
    address is Yellow Building, 1A Nicholas Road, London, W11
    4AN.

    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@**
    googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>.
    For more options, visit this group at http://groups.google.com/**
    group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en>
    .

    --
    Nicolas Di Gregorio
    25A, Rue des Pyramides
    7700 Mouscron
    Belgium
    Tel: +32479820183
    @: nicolas.digregorio@gmail.com

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Digrouz at Apr 24, 2012 at 9:57 am
    I just found my problem,

    It is in the split in fact I don't have space between the value but
    carried returns, so if I split to "\n", it works.

    Regards
    On 24 avr, 10:55, Luke Bigum wrote:
    Very close:

    <% virtualmountpoints.each do |fs| -%>
    [<%= fs %>]
    virtualmountpoint<%= fs %>
    <% end -%>

    I don't understand the Ruby in that, I copied it from someone else ;-)

    On 24/04/12 09:18, digrouz wrote:








    Hello guys,
    I would like to get some help with puppet about using an array in a
    template.
    I've a custom facts that return me this:
    tsm_vmp    / /home /tmp /var/tmp /usr /var
    I have a class that use this facts to split it on every space and to a
    an entry in a template for each value, here is the code I use for
    this:
    $virtualmountpoints = split($tsm_vmp, ' ')
    ...
    "/opt/tivoli/tsm/client/ba/bin/dsm.sys":
    owner =>  root,
    group =>  root,
    mode =>  0600,
    content =>  template("tsm/dsm.sys.erb"),
    That's what's I have in my template
    <% virtualmountpoints.each do |fs| -%>
    virtualmountpoint<%= fs %>
    <% end -%>
    Thats what I get:
    virtualmountpoint /
    /home
    /tmp
    /var/tmp
    /usr
    /var
    but I would like to get instead:
    virtualmountpoint /
    virtualmountpoint /home
    virtualmountpoint /tmp
    virtualmountpoint /var/tmp
    virtualmountpoint /usr
    virtualmountpoint /var
    Do you know how to do this?
    --
    Luke Bigum

    Information Systems
    Ph: +44 (0) 20 3192 2520
    luke.bi...@lmax.com |http://www.lmax.com
    LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN

    FX and CFDs are leveraged products that can result in losses exceeding
    your deposit.  They are not suitable for everyone so please ensure you
    fully understand the risks involved.  The information in this email is not
    directed at residents of the United States of America or any other
    jurisdiction where trading in CFDs and/or FX is restricted or prohibited
    by local laws or regulations.

    The information in this email and any attachment is confidential and is
    intended only for the named recipient(s). The email may not be disclosed
    or used by any person other than the addressee, nor may it be copied in
    any way. If you are not the intended recipient please notify the sender
    immediately and delete any copies of this message. Any unauthorised
    copying, disclosure or distribution of the material in this e-mail is
    strictly forbidden.

    LMAX operates a multilateral trading facility.  Authorised and regulated
    by the Financial Services Authority (firm registration number 509778) and
    is registered in England and Wales (number 06505809).
    Our registered address is Yellow Building, 1A Nicholas Road, London, W11
    4AN.
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Krzysztof Wilczynski at Apr 24, 2012 at 11:32 am
    Hi,

    [...]
    It is in the split in fact I don't have space between the value but
    carried returns, so if I split to "\n", it works.
    This is slightly worrisome. I encourage you to go with separating values
    with a comma, not only because it follows style of how other facts return
    values, but also ensures that things will not break by accident (something
    may happen now and/or in the future). As far as having single space there
    to separate results is also acceptable, then having "\n" there might not be
    what you want. I do encourage you to strip surplus new lines and join
    values on single comma :)

    My 2p, I hope you don't mind :)

    KW

    --
    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/-/95nyFfV8ytsJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 24, '12 at 8:49a
activeApr 24, '12 at 11:32a
posts5
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase