summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Smoogen <smooge@redhat.com>2016-05-24 21:30:08 +0000
committerStephen Smoogen <smooge@redhat.com>2016-05-24 21:30:08 +0000
commit236cce523dd2b61d4d213d7c767da386e35542c9 (patch)
tree2bc0dd1d73b07fffa3eb6517b5f1cc21aa5a7edc
parentac35a48d8cc6ef4207671ccce3bf870f7552e4b5 (diff)
downloadansible-236cce523dd2b61d4d213d7c767da386e35542c9.tar.gz
ansible-236cce523dd2b61d4d213d7c767da386e35542c9.tar.xz
ansible-236cce523dd2b61d4d213d7c767da386e35542c9.zip
we use playbooks and not scripts
-rwxr-xr-xscripts/needs-reboot88
-rwxr-xr-xscripts/needs-updates90
2 files changed, 0 insertions, 178 deletions
diff --git a/scripts/needs-reboot b/scripts/needs-reboot
deleted file mode 100755
index fc312ade9..000000000
--- a/scripts/needs-reboot
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-
-# (c) 2012, Red Hat, Inc
-# Seth Vidal <skvidal at fedoraproject.org>
-#
-#
-########################################################
-
-import sys
-import getpass
-
-import ansible.runner
-import ansible.constants as C
-from ansible import utils
-from ansible import callbacks
-
-########################################################
-
-def main(args):
-
- # simple parser
- parser = utils.base_parser(constants=C, runas_opts=True, async_opts=False,
- 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('--needsreboot', dest='needsreboot', help="command to run for needs-reboot",
- default="/usr/local/bin/needs-reboot.py")
- options, args = parser.parse_args(args)
- options.module_name = 'command'
- options.module_args = options.needsreboot
-
- # no hosts specified? Run against all of them
- if not options.hostlist:
- options.pattern = 'all'
- else:
- options.pattern = ';'.join(options.hostlist)
-
- # setup the cli call back so we can use the simple output handling
- # our callbacks for easy terminal formatting
-
- mycallback = callbacks.DefaultRunnerCallbacks()
- mycallback.options = options
-
- runner = ansible.runner.Runner(
- module_name=options.module_name, module_path=options.module_path,
- module_args=options.module_args,
- remote_user=options.remote_user,
- host_list=options.inventory, timeout=options.timeout,
- forks=options.forks,
- pattern=options.pattern,
- callbacks=mycallback,
- transport=options.connection
- )
-
- needsreboot = []
- results = runner.run()
- for (host,d) in results['contacted'].items():
- answer = d.get('stdout', 'null').strip()
- if answer == 'yes':
- needsreboot.append(host)
- elif answer == 'no':
- pass
- else:
- if d.get('failed', False):
- err = d.get('stderr', '').strip()
- if err:
- 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)
-
- for host in results['dark']:
- print >> sys.stderr, 'Error: Could not reach: %s' % host
-
- for host in sorted(needsreboot):
- print host
-
-
-
-
-if __name__ == '__main__':
- try:
- main(sys.argv)
- except Exception, e:
- # Generic handler for ansible specific errors
- print "ERROR: %s" % str(e)
- sys.exit(1)
-
diff --git a/scripts/needs-updates b/scripts/needs-updates
deleted file mode 100755
index ca1740395..000000000
--- a/scripts/needs-updates
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-
-# (c) 2012, Red Hat, Inc
-# Seth Vidal <skvidal at fedoraproject.org>
-#
-#
-########################################################
-
-import sys
-import getpass
-
-import ansible.runner
-import ansible.constants as C
-from ansible import utils
-from ansible import callbacks
-
-########################################################
-
-def main(args):
-
- # simple parser
- parser = utils.base_parser(constants=C, runas_opts=True, async_opts=False,
- 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
- options.module_name = 'yum'
- options.module_args = 'list=updates'
-
-
- # no hosts specified? Run against all of them
- if not options.hostlist:
- options.pattern = 'all'
- else:
- options.pattern = ';'.join(options.hostlist)
-
- # setup the cli call back so we can use the simple output handling
- # our callbacks for easy terminal formatting
-
- mycallback = callbacks.DefaultRunnerCallbacks()
- mycallback.options = options
-
- runner = ansible.runner.Runner(
- module_name=options.module_name, module_path=options.module_path,
- module_args=options.module_args,
- remote_user=options.remote_user,
- host_list=options.inventory,
- timeout=300,
- forks=100,
- pattern=options.pattern,
- callbacks=mycallback
- )
- print "Checking for updates on %s" % (options.pattern)
-
- updates = ""
- needsupdate = []
- results = runner.run()
- for (host,d) in results['contacted'].items():
- answer = d.get('results', [])
- if 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()
- if err:
- 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)
-
- for (host,d) in results['dark'].items():
- print "%s failed because (%s)" % (host,d)
-
- for host in sorted(needsupdate):
- print host
-
-if __name__ == '__main__':
- try:
- main(sys.argv)
- except Exception, e:
- # Generic handler for ansible specific errors
- print "ERROR: %s" % str(e)
- sys.exit(1)