whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added

in 0.6 release)
This commit is contained in:
Michael DeHaan 2012-08-06 20:07:02 -04:00
commit faed4b5a33
36 changed files with 306 additions and 450 deletions

View file

@ -33,35 +33,35 @@ from ansible import inventory
class Cli(object):
''' code behind bin/ansible '''
# ----------------------------------------------
# ----------------------------------------------
def __init__(self):
self.stats = callbacks.AggregateStats()
self.callbacks = callbacks.CliRunnerCallbacks()
# ----------------------------------------------
# ----------------------------------------------
def parse(self):
''' create an options parser for bin/ansible '''
parser = utils.base_parser(constants=C, runas_opts=True, async_opts=True,
output_opts=True, connect_opts=True, usage='%prog <host-pattern> [options]')
parser.add_option('-a', '--args', dest='module_args',
help="module arguments", default=C.DEFAULT_MODULE_ARGS)
parser.add_option('-m', '--module-name', dest='module_name',
help="module name to execute (default=%s)" % C.DEFAULT_MODULE_NAME,
help="module name to execute (default=%s)" % C.DEFAULT_MODULE_NAME,
default=C.DEFAULT_MODULE_NAME)
options, args = parser.parse_args()
self.callbacks.options = options
self.callbacks.options = options
if len(args) == 0 or len(args) > 1:
parser.print_help()
sys.exit(1)
return (options, args)
# ----------------------------------------------
return (options, args)
# ----------------------------------------------
def run(self, options, args):
''' use Runner lib to do SSH things '''
@ -72,7 +72,7 @@ class Cli(object):
if len(hosts) == 0:
print >>sys.stderr, "No hosts matched"
sys.exit(1)
sshpass = None
sudopass = None
if options.ask_pass:
@ -90,11 +90,11 @@ class Cli(object):
module_name=options.module_name, module_path=options.module_path,
module_args=options.module_args,
remote_user=options.remote_user, remote_pass=sshpass,
inventory=inventory_manager, timeout=options.timeout,
inventory=inventory_manager, timeout=options.timeout,
private_key_file=options.private_key_file,
forks=options.forks,
pattern=pattern,
callbacks=self.callbacks, sudo=options.sudo,
forks=options.forks,
pattern=pattern,
callbacks=self.callbacks, sudo=options.sudo,
sudo_pass=sudopass,sudo_user=options.sudo_user,
transport=options.connection, verbose=options.verbose
)
@ -108,7 +108,7 @@ class Cli(object):
return (runner, results)
# ----------------------------------------------
# ----------------------------------------------
def poll_while_needed(self, poller, options):
''' summarize results from Runner '''

View file

@ -87,15 +87,15 @@ def main(args):
pb = ansible.playbook.PlayBook(
playbook=playbook,
module_path=options.module_path,
host_list=options.inventory,
forks=options.forks,
verbose=options.verbose,
host_list=options.inventory,
forks=options.forks,
verbose=options.verbose,
remote_user=options.remote_user,
remote_pass=sshpass,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
remote_pass=sshpass,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
stats=stats,
timeout=options.timeout,
timeout=options.timeout,
transport=options.connection,
sudo=options.sudo,
sudo_user=options.sudo_user,

View file

@ -5,7 +5,7 @@
# example playbook to bootstrap this script in the examples/ dir which
# installs ansible and sets it up to run on cron.
#
# usage:
# usage:
# ansible-pull -d /var/ansible/local -U http://wherever/content.git -C production
#
# the git repo must contain a playbook named 'local.yml'