Revert "Fixes #3973 live output for ansible-pull"
This reverts commit 3b2a35ae00
.
This commit is contained in:
parent
3b2a35ae00
commit
ebeaf785b5
1 changed files with 2 additions and 44 deletions
|
@ -45,8 +45,6 @@ import sys
|
|||
import datetime
|
||||
import socket
|
||||
from ansible import utils
|
||||
import shlex
|
||||
import select
|
||||
|
||||
DEFAULT_REPO_TYPE = 'git'
|
||||
DEFAULT_PLAYBOOK = 'local.yml'
|
||||
|
@ -54,38 +52,6 @@ PLAYBOOK_ERRORS = {1: 'File does not exist',
|
|||
2: 'File is not readable'}
|
||||
|
||||
|
||||
def _run_verbose(cmd):
|
||||
cmdargs = shlex.split(cmd)
|
||||
p = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
stdout = ''
|
||||
stderr = ''
|
||||
rpipes = [p.stdout, p.stderr]
|
||||
while True:
|
||||
rfd, wfd, efd = select.select(rpipes, [], rpipes, 1)
|
||||
|
||||
if p.stdout in rfd:
|
||||
dat = os.read(p.stdout.fileno(), 100)
|
||||
sys.stdout.write(dat)
|
||||
stdout += dat
|
||||
if dat == '':
|
||||
rpipes.remove(p.stdout)
|
||||
if p.stderr in rfd:
|
||||
dat = os.read(p.stderr.fileno(), 100)
|
||||
stderr += dat
|
||||
sys.stdout.write(dat)
|
||||
if dat == '':
|
||||
rpipes.remove(p.stderr)
|
||||
# only break out if we've emptied the pipes, or there is nothing to
|
||||
# read from and the process has finished.
|
||||
if (not rpipes or not rfd) and p.poll() is not None:
|
||||
break
|
||||
# Calling wait while there are still pipes to read can cause a lock
|
||||
elif not rpipes and p.poll() == None:
|
||||
p.wait()
|
||||
|
||||
return p.returncode, stdout
|
||||
|
||||
def _run(cmd):
|
||||
print >>sys.stderr, "Running: '%s'" % cmd
|
||||
cmd = subprocess.Popen(cmd, shell=True,
|
||||
|
@ -136,8 +102,6 @@ def main(args):
|
|||
""" Set up and run a local playbook """
|
||||
usage = "%prog [options] [playbook.yml]"
|
||||
parser = utils.SortedOptParser(usage=usage)
|
||||
parser.add_option('-v', '--verbose', default=False, action='store_true',
|
||||
help='Print the ansible-playbook output while running')
|
||||
parser.add_option('--purge', default=False, action='store_true',
|
||||
help='purge checkout after playbook run')
|
||||
parser.add_option('-o', '--only-if-changed', dest='ifchanged', default=False, action='store_true',
|
||||
|
@ -177,10 +141,7 @@ def main(args):
|
|||
|
||||
inv_opts = 'localhost,'
|
||||
limit_opts = 'localhost:%s:127.0.0.1' % hostname
|
||||
if not options.verbose:
|
||||
base_opts = '-c local --limit "%s"' % limit_opts
|
||||
else:
|
||||
base_opts = '-vvvv -c local --limit "%s"' % limit_opts
|
||||
base_opts = '-c local --limit "%s"' % limit_opts
|
||||
repo_opts = "name=%s dest=%s" % (options.url, options.dest)
|
||||
if options.checkout:
|
||||
repo_opts += ' version=%s' % options.checkout
|
||||
|
@ -211,10 +172,7 @@ def main(args):
|
|||
if options.inventory:
|
||||
cmd += ' -i "%s"' % options.inventory
|
||||
os.chdir(options.dest)
|
||||
if not options.verbose:
|
||||
rc, out = _run(cmd)
|
||||
else:
|
||||
rc, out = _run_verbose(cmd)
|
||||
rc, out = _run(cmd)
|
||||
|
||||
if options.purge:
|
||||
os.chdir('/')
|
||||
|
|
Loading…
Reference in a new issue