简体   繁体   中英

Puppet - How can I compare value of manifest variable against index from a loop in Template

Hi I'm trying to compare two values one value in manifest and other in a puppet template, How can I to this, I have tried the following it doesn't go into the If statement.

puppet.pp

$i = 0
$values = [val1, val2, otherval]

$var2 = template("/home/cluster/temp.erb")

notice ("This Current Location  ${var2}")

temp.erb

 <% @values.each_with_index do |this_server, idx| -%>

        <% if idx==@i -%>  #This is where I want to check

               If True!!!! 

        <% end -%>

               Out OF IFFF

 <% end -%>

How can I compare value of manifest variable against index from a loop in Template. Thanks in advance.

I found the issue after converting the value to an integer everything works fine.

The following was modified.

<% if idx==@i.to_i -%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM