Arithmetic operations inside patterns

I am trying to add a number to a parameter inside a puppet template as shown below

"https://localhost:<%= 9443 + @offset %>/service/" 

This gives me the following error.

Details: A string cannot be forced into Fixnum

'offset' is a numeric value. Is it possible to perform such arithmetic operations in the puppet?

+6
source share
1 answer

Everything in the puppet is parsed as a string. Try the following:

 "https://localhost:<%= 9443 + @offset.to_i %>/service/" 

or

 "https://localhost:<%= 9443 + Integer(@offset) %>/service/" 

Hope this helps.

+7
source

Source: https://habr.com/ru/post/977541/


All Articles