Re: [Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-13 Thread Rob Nelson
There's also `last reboot -1`, add your favorite timestamp format with -T :) Rob Nelson rnels...@gmail.com On Fri, Jan 13, 2017 at 6:27 AM, Thomas Müller wrote: > > > Am Dienstag, 10. Januar 2017 17:44:23 UTC+1 schrieb Denny: >> >> Hi there, >> >> probably a pretty easy

[Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-13 Thread Thomas Müller
Am Dienstag, 10. Januar 2017 17:44:23 UTC+1 schrieb Denny: > > Hi there, > > probably a pretty easy to answer question. > > I want to try out adding custom facts. My first custom fact should be > "lastrebootdate" > > My code looks like this: > > Facter.add(:lastrebootdate) do > setcode do >

Re: [Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-10 Thread Rob Nelson
Thanks for the correction. Definitely way off base on that, my apologies for the erroneous claims! Rob Nelson rnels...@gmail.com On Tue, Jan 10, 2017 at 4:46 PM, Stefan Schulte wrote: > Hey Rob, > > variable interpolation in strings in ruby is actually done with >

Re: [Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-10 Thread Stefan Schulte
Hey Rob, variable interpolation in strings in ruby is actually done with #{some_var}, so the following snippet #!/usr/bin/ruby "Hello World".match(/Hello (.*)/) puts $1 puts "$1" puts "#{$1} actually returns World $1 World As you can see "$1" does not

[Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-10 Thread Rob Nelson
At a guess, dollar signs inside double quotes interpolate, so it's extremely possible that somewhere earlier in the ruby run, $3 matched "Jan" somewhere and that was reused in your awk command. In the latter usage there's probably no $6 (that's a lot of matches!) or it amazingly has the value

[Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-10 Thread Denny
Tried out another customfact "lastyumupdate" which looks like: Facter.add(:lastyumupdate) do setcode do Facter::Util::Resolution.exec("yum history |grep -E '^.*(Update| U).*$' |head -n 1 |awk '{print $6}'") end end This one returns on command line "2017-01-10" AND sets the fact correct

[Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-10 Thread Denny
Tried out another customfact "lastyumupdate" which looks like: Facter.add(:lastyumupdate) do setcode do Facter::Util::Resolution.exec("yum history |grep -E '^.*(Update| U).*$' |head -n 1 |awk '{print↪$6}'") end end This one returns on command line "2017-01-10" AND sets the fact

[Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-10 Thread Denny
PS: I'm running facter 3.5.0 with puppet 4.8.1 on CentOS 7 Am Dienstag, 10. Januar 2017 17:44:23 UTC+1 schrieb Denny: > > Hi there, > > probably a pretty easy to answer question. > > I want to try out adding custom facts. My first custom fact should be > "lastrebootdate" > > My code looks like