简体   繁体   中英

puppet compare string in the erb template

We have puppet version 3.8.7. I have the facter that return the version of dovecot: 2.2 or 2.3. In the erb-template I have the next construction:

# SSL/TLS protocols to use
111 <% if @dovecot_version =~ "2.2" -%>
112 ssl_protocols = !SSLv2 !SSLv3
113 
114 # Diffie-Hellman parameters length
115 ssl_dh_parameters_length = 2048
116 <% else -%>
117 ssl_min_protocol = SSLv3
118 
119 # Diffie-Hellman parameters length
120 #ssl_dh_parameters_length = 2048
121 <% end -%>    

After apply I see the next error message:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template cpanel/dovecot.conf.erb:
  Filepath: org/jruby/RubyString.java
  Line: 1730
  Detail: type mismatch: String given
at /etc/puppet/environments/testing/modules/cpanel/manifests/dovecot.pp:34 on node server1.development.local
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Whats wrong with variable type? How I can compare the strings? Thanks for your answer

Ruby's =~ operator is for matching strings to regular expressions. The operands may appear in either order, but one needs to be a regex. In your case, both are strings.

To compare strings for equality, use the ordinary == or != operator.

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