summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKevin Fenzi <kevin@scrye.com>2015-04-14 22:02:36 +0000
committerKevin Fenzi <kevin@scrye.com>2015-04-14 22:02:36 +0000
commitda541362d033e84913840b92385d6e2d39dc38fb (patch)
treeca2a85e0ce6dcc41c51331fc5b37e07069ca9bcc /scripts
parentfb7e6e541b48bb26bc050b5538f69295c548deb8 (diff)
downloadansible-da541362d033e84913840b92385d6e2d39dc38fb.tar.gz
ansible-da541362d033e84913840b92385d6e2d39dc38fb.tar.xz
ansible-da541362d033e84913840b92385d6e2d39dc38fb.zip
Add check-host playbook from ticket 4290. Many thanks doteast!
Diffstat (limited to 'scripts')
-rw-r--r--[-rwxr-xr-x]scripts/needs-updates20
1 files changed, 12 insertions, 8 deletions
diff --git a/scripts/needs-updates b/scripts/needs-updates
index dd9be9d90..494b23fa4 100755..100644
--- a/scripts/needs-updates
+++ b/scripts/needs-updates
@@ -23,7 +23,11 @@ def main(args):
output_opts=True, connect_opts=True, usage='ans-command [options]')
parser.add_option('--host', dest='hostlist', action='append',
help="hosts to contact, defaults to all in your inventory", default=[])
+ parser.add_option('-l','--list', dest='listupdates', action='store_true',
+ help="list the updates needed", default=False)
options, args = parser.parse_args(args)
+ list_updates=options.listupdates
+ del options.listupdates
options.module_name = 'yum'
options.module_args = 'list=updates'
@@ -51,13 +55,17 @@ def main(args):
transport=options.connection
)
+ updates = ""
needsupdate = []
results = runner.run()
for (host,d) in results['contacted'].items():
answer = d.get('results', [])
if answer:
- needsupdate.append('%s : %s' % (host, len(answer)))
-
+ updates="%s:%s" % (host,len(answer))
+ if list_updates:
+ for update in answer:
+ updates+=",%s" % update['name']
+ needsupdate.append(updates)
else:
if d.get('failed', False):
err = d.get('stderr', '').strip()
@@ -65,16 +73,13 @@ def main(args):
print >> sys.stderr, 'Error: %s said %s' % (host, err)
msg = d.get('msg', '').strip()
if msg:
- print >> sys.stderr, 'Error: %s said %s' % (host, msg)
+ print >> sys.stderr, 'Error: %s said %s' % (host, msg)
for host in results['dark']:
print >> sys.stderr, 'Error: Could not reach: %s' % host
-
+
for host in sorted(needsupdate):
print host
-
-
-
if __name__ == '__main__':
try:
@@ -83,4 +88,3 @@ if __name__ == '__main__':
# Generic handler for ansible specific errors
print "ERROR: %s" % str(e)
sys.exit(1)
-