[rudder-users] Get number of package to be upgraded (apt)

Francois Armand francois.armand at normation.com
Tue Aug 25 11:24:07 CEST 2015


On 24/08/2015 18:23, Julien Escario wrote:
> Le 24/08/2015 17:43, Nicolas Charles a écrit :
>> The workaround I can suggest is to use the command
>>
>> ! /usr/bin/apt-get -s upgrade | /bin/grep Inst|wc -l
>>
>> which would do the same.
> OK, works exactly as expected. Got a big red error, just how I like them ;-)
>
>> The consequence will be that the Directive will return status:
>>
>>   * Repaired if there are no package to upgrade
>>   * Error if there are packages to upgrade
>>
>> The logic is that command_execution will return status "Repaired" for exit code
>> 0, and "Error" for non exit code 0
>>
>>
>> Does that do what you want ?
> Yup, more or less. It would be nice to be able to report something else than 0
> or 1. To comply with directive, a 'threshold' should be added.
>
> But I'm perhaps far from the concept of rudder.
>
> At least, I have an information about system being up-to-date or not. Added with
> a few packahe version check for critical packages (openssl, bind, ssh, ...), I
> think we'll be able to get a start of what we need.
>
> Lemme check this a couple hours more and I'll come back with more questions
> about how to do this or that ;-)
>
> Thanks for your help,
> Julien
>
>
>
> _______________________________________________
> rudder-users mailing list
> rudder-users at lists.rudder-project.org
> http://www.rudder-project.org/mailman/listinfo/rudder-users


Hello,

I'm not sur about what you want exactly, but is failry easy to add new
generic method, tailored for you need. Typically, if the "command"
methods doesn't do what you want, you could add your own, that handle
return code differently, and reports more preciselly what are the
packages not up to date. Actually, you could even add a
"is_system_up_to_date" method that is success if everything up to date,
error if not, BUT alse report all the packages not up to date.


There is some example here of generic methods I created for some demo:
https://gist.github.com/fanf/83ade79362bf51c44465
(I'm not a CFEngine expert at all (that's Nicolas and Benoit and
others), mainly used copy&paste from other generic methods :)

Don't hesitate if you want more information about how to add methods, or
if you have some specs for your need and don't know how to transform
them in methods.

Hope it helps,

-- 
Nouveau site web Normation
------------------------------------------------------------------------
*François ARMAND*
/Co-founder & CTO/
Normation <http://www.normation.com>
------------------------------------------------------------------------
*87 rue de Turbigo, 75003 Paris, France*
Telephone: 	+33 (0)1 83 62 99 23
Mobile: 	+33 (0)6 63 37 60 55
------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rudder-project.org/pipermail/rudder-users/attachments/20150825/ba17205d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo-newsite.gif
Type: image/gif
Size: 24554 bytes
Desc: not available
URL: <http://www.rudder-project.org/pipermail/rudder-users/attachments/20150825/ba17205d/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo-square.gif
Type: image/gif
Size: 1036 bytes
Desc: not available
URL: <http://www.rudder-project.org/pipermail/rudder-users/attachments/20150825/ba17205d/attachment-0003.gif>


More information about the rudder-users mailing list