FAQ
In an .erb template, I want to test if a value is in an array (and if yes
do something).

I thought the way to do it might me something like:

<% if @testservers.include? @fqdn %>
environment = test
<% else %>
environment = production
<% end %>

However that blows up complaining that .include is an undefined function.

Our version of puppet is 2.6.16 on the client and 2.7.12 on the
puppetmaster.

Can anyone help?

--
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/-/1SMg1cuLUiIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Jcbollinger at Aug 27, 2012 at 6:32 pm

    On Tuesday, August 21, 2012 10:42:16 AM UTC-5, LTH wrote:
    In an .erb template, I want to test if a value is in an array (and if yes
    do something).

    I thought the way to do it might me something like:

    <% if @testservers.include? @fqdn %>
    environment = test
    <% else %>
    environment = production
    <% end %>

    However that blows up complaining that .include is an undefined function.

    It will do so if @testservers is not an array (or, more properly, if it
    does not have a method named "include?"). Perhaps this will do what you
    want:

    <% if (defined? @testservers) and (@testservers.class == 'Array') and
    (@testservers.include? @fqdn) %>


    John

    --
    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/-/fWX3fcS_qccJ.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    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
postedAug 21, '12 at 5:05p
activeAug 27, '12 at 6:32p
posts2
users2
websitepuppetlabs.com

2 users in discussion

LTH: 1 post Jcbollinger: 1 post

People

Translate

site design / logo © 2023 Grokbase