简体   繁体   English

Puppet-如何从模板中的循环比较清单变量的值与索引

[英]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. 嗨,我正在尝试比较清单文件中的一个值和人偶模板中的另一个值,如何对此进行比较,我尝试了以下方法,并将其不包含在If语句中。

puppet.pp puppet.pp

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

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

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

temp.erb 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 -%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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