How to convert a string to integer in Puppet?

You can do this:

$n_timeout = 0 + $timeout


I've taken to using the scanf function in stdlib.

An example of this:

$ram = scanf("${::memorysize_mb}", "%i")

This requires puppet >= 3.7.5


Your code will work exactly as defined; Puppet implicitly converts strings and integers as appropriate for the comparison operator being used.


Puppet 4: $odd_ip = Integer($ip_array[3]) % 2

Taken from https://github.com/puppetlabs/puppetlabs-apt/pull/743/files