FAQ
Hi!

I am trying to match a string in an ERB template but for what ever reason
it does not work.

<% if has_variable?("apache2_phpmyadmin_url") && apache2_phpmyadmin_url !=
"" then %>
ProxyPass /<%= apache2_phpmyadmin_url %>/ !
<% end %>

The conditional works on has_variable? but the != "" is not getting
evaluated. When the variable is set to "" than the Proxypass is set to /
instead of being left out.

Any ideas what I am doing wrong?

Best Regards,

Dan

--
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/-/ReEPMs9_8w0J.
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

  • Stefan Schulte at Aug 4, 2012 at 6:46 pm

    On Sat, Aug 04, 2012 at 03:10:11AM -0700, danielt wrote:
    Hi!

    I am trying to match a string in an ERB template but for what ever reason
    it does not work.

    <% if has_variable?("apache2_phpmyadmin_url") && apache2_phpmyadmin_url !=
    "" then %>
    ProxyPass /<%= apache2_phpmyadmin_url %>/ !
    <% end %>

    The conditional works on has_variable? but the != "" is not getting
    evaluated. When the variable is set to "" than the Proxypass is set to /
    instead of being left out.

    Any ideas what I am doing wrong?

    Best Regards,

    Dan
    Are you sure the variable is an empty string? I just did a short test
    myself and your example does work for me.

    try to modify your ProxyPass line to

    ProxyPass /<%= apache2_phpmyadmin_url.inspect %>/ !

    This way an empty string should appear as "" and you may find out that
    apache2_phpmyadmin_url does contain some spaces or is not a string at
    all.

    Sitenote: The documentation recommends to reference your variables as
    instance variables [1] to avoid nameclashes with ruby functions [2].
    This way your template could look like this

    <% if @apache2_phpmyadmin_url and !@apache2_phpmyadmin_url.empty? -%>
    ProxyPass /<%= @apache2_phpmyadmin_url %>/ !
    <% end -%>

    [1] http://docs.puppetlabs.com/guides/templating.html#referencing-variables
    [2] http://projects.puppetlabs.com/issues/14527


    -Stefan

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 4, '12 at 2:55p
activeAug 4, '12 at 6:46p
posts2
users2
websitepuppetlabs.com

2 users in discussion

Stefan Schulte: 1 post Danielt: 1 post

People

Translate

site design / logo © 2022 Grokbase