Object: to get a custom fact that lets me know the last time a Ubuntu system 
had run 'upgrade' (ie apt-get upgrade or aptitude [safe-|full-]upgrade)

One-liner: (will probably still need some adaptation but so far, I am doing)
tac /var/log/apt/history.log | \
  awk '{if (substr($0,1,8)=="Upgrade:") { getline; print }}' \
  | head -n 1

which will return something like: 'Start-Date: 2011-11-21  23:51:47' which I 
can cut the date out of and store as a custom fact - ie... last_upgrade:

The problem is that the logs rotate and now this may be in 
/var/log/apt/history.2.gz or possibly get rotated out of existence altogether 
and while I can loop and search for the last time an upgrade was run, I may not 
actually be able to get that date and would want the last_upgrade to persist.

Now I could conceivably store this value in say /var/lib/puppet/last_upgrade so 
I always have a fallback, I'm wondering if there isn't a better way.

Comments - Ideas?

-- 
Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [email protected]
1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com 

Need help communicating between generations at work to achieve your desired 
success? Let us help!

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to