make it output number of pkgs neeed to be updated per host
This commit is contained in:
parent
33d9363211
commit
90d3275e54
1 changed files with 8 additions and 8 deletions
|
@ -24,9 +24,10 @@ def main(args):
|
||||||
parser.add_option('--host', dest='hostlist', action='append',
|
parser.add_option('--host', dest='hostlist', action='append',
|
||||||
help="hosts to contact, defaults to all in your inventory", default=[])
|
help="hosts to contact, defaults to all in your inventory", default=[])
|
||||||
options, args = parser.parse_args(args)
|
options, args = parser.parse_args(args)
|
||||||
options.module_name = 'shell'
|
options.module_name = 'yum'
|
||||||
options.module_args = 'yum check-update > /dev/null'
|
options.module_args = 'list=updates'
|
||||||
|
|
||||||
|
|
||||||
# no hosts specified? Run against all of them
|
# no hosts specified? Run against all of them
|
||||||
if not options.hostlist:
|
if not options.hostlist:
|
||||||
options.pattern = 'all'
|
options.pattern = 'all'
|
||||||
|
@ -53,11 +54,10 @@ def main(args):
|
||||||
needsupdate = []
|
needsupdate = []
|
||||||
results = runner.run()
|
results = runner.run()
|
||||||
for (host,d) in results['contacted'].items():
|
for (host,d) in results['contacted'].items():
|
||||||
answer = d.get('rc', '0')
|
answer = d.get('results', [])
|
||||||
if answer == 100:
|
if answer:
|
||||||
needsupdate.append(host)
|
needsupdate.append('%s : %s' % (host, len(answer)))
|
||||||
elif answer == 0:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
if d.get('failed', False):
|
if d.get('failed', False):
|
||||||
err = d.get('stderr', '').strip()
|
err = d.get('stderr', '').strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue