Facter.add(:lastrebootdate) do setcode do Facter::Util::Resolution.exec("/usr/bin/who -b |awk '{print $3}'") endend
$ puppet facts |grep lastrebootdate
"lastrebootdate": "Jan",
Facter.add(:lastyumupdate) do setcode do Facter::Util::Resolution.exec("yum history |grep -E '^.*(Update| U).*$' |head -n 1 |awk '{print $6}'") endend
$ puppet facts |grep last "lastrebootdate": "Jan", "lastyumupdate": "2017-01-10",
> an email to puppet-users+unsubscribe@googlegroups.com
> <mailto:puppet-users+unsub...@googlegroups.com>.
> To view this discussion on the web visit
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ccb700cd-6bf1-14dc-84cf-9b75d7181eca%40posteo.de.
% LC_ALL=de_DE.utf8 /usr/bin/who -b |awk '{print $3}'
19:34
% LC_ALL=en_US.utf8 /usr/bin/who -b |awk '{print $3}'
2017-01-10
% LC_ALL=C /usr/bin/who -b |awk '{print $3}'
Jan
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
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) dosetcode doFacter::Util::Resolution.exec("/usr/bin/who -b |awk '{print $3}'")endend
Running the command on the system returns "2017-01-30"
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/41898ce0-c5e3-472f-98f9-eb4fbae47aa8%40googlegroups.com.