Re: [Puppet Users] My custom puppet function changes values

2016-05-18 Thread Trevor Vaughan
This should work in all versions of Ruby (YMMV) 'foo.bar.baz'.each_byte.map{|x| x}.join.to_i % 64511 + 1024 Trevor On Wed, May 18, 2016 at 7:37 PM, p wrote: > I'm doing this instead: > module Puppet::Parser::Functions > newfunction(:ip_port, :type => :rvalue) do |args| > require 'zlib' >

Re: [Puppet Users] My custom puppet function changes values

2016-05-18 Thread p
I'm doing this instead: module Puppet::Parser::Functions newfunction(:ip_port, :type => :rvalue) do |args| require 'zlib' Zlib.crc32(args[0]) % 64511 + 1024 end end On Wednesday, May 18, 2016 at 10:16:19 AM UTC-7, p wrote: > > Any suggestions on how I can get the hash of the string

Re: [Puppet Users] My custom puppet function changes values

2016-05-18 Thread p
Any suggestions on how I can get the hash of the string content itself so I can get this function to work? I really just don't want to manage ports anymore. On Wednesday, May 18, 2016 at 7:35:55 AM UTC-7, Trevor Vaughan wrote: > > Hi Peter, > > Object.hash in Ruby provides the hash of the Object

Re: [Puppet Users] My custom puppet function changes values

2016-05-18 Thread p
Thanks, Trevor. I did and as you had predicted they are different. On Wednesday, May 18, 2016 at 7:35:55 AM UTC-7, Trevor Vaughan wrote: > > Hi Peter, > > Object.hash in Ruby provides the hash of the Object ID, not a consistent > cryptographic hash of the string provided. > > Try it in two differ

Re: [Puppet Users] My custom puppet function changes values

2016-05-18 Thread Trevor Vaughan
Hi Peter, Object.hash in Ruby provides the hash of the Object ID, not a consistent cryptographic hash of the string provided. Try it in two different IRB sessions and you'll see what I mean. It will change between garbage collection runs and/or at every invocation of Puppet if done in cron. Trev