Skip to content
Snippets Groups Projects
Commit d87ddb0a authored by František Dvořák's avatar František Dvořák
Browse files

Flush progress output (for run inside terraform)

parent 1c2fd6f6
No related branches found
No related tags found
No related merge requests found
Pipeline #623 passed
......@@ -24,7 +24,7 @@ def perform_command(cmd, waitExitCode=None):
global elapsed
desc = ' '.join(map(escape_cmd, cmd))
print('-> %s' % desc)
print('-> %s' % desc, flush=True)
start = time.perf_counter()
if not args.dry_run:
count = 1
......@@ -33,7 +33,7 @@ def perform_command(cmd, waitExitCode=None):
while ret is None or ret != waitExitCode:
time.sleep(5)
count += 1
print('->(%d) %s' % (count, desc))
print('->(%d) %s' % (count, desc), flush=True)
ret = subprocess.call(cmd)
end = time.perf_counter()
fperf.write('[%f] (%d) %s\n' % (end - start, count, desc))
......@@ -91,7 +91,7 @@ ssh = [args.ssh] + args.ssh_opts.split(r' ')
fperf = open('perf.log', buffering=1, mode='at')
print('== plugin ==')
print('== plugin ==', flush=True)
if t and os.path.exists('deployments/%s/plugin.py' % t):
print('-> deployments/%s/plugin.py' % t)
plugin = importlib.import_module('deployments.%s.plugin' % t)
......@@ -101,7 +101,7 @@ else:
component = None
if 'files' in args.actions:
print('== files ==')
print('== files ==', flush=True)
print('-> hosts')
if not args.dry_run:
with open('hosts', 'w') as f:
......@@ -147,7 +147,7 @@ ansible_ssh_common_args=\'%s -o ForwardAgent=yes -o ProxyCommand="ssh -W {{ ansi
component.action('files')
if 'ping' in args.actions:
print('== ping ==')
print('== ping ==', flush=True)
cmd = ['ping', '-c', '1', '-i', '2', '-q', master_ip]
perform_command(cmd, 0)
cmd = ['ssh-keygen', '-R', master_ip]
......@@ -166,7 +166,7 @@ if 'ping' in args.actions:
component.action('ping')
if 'init' in args.actions:
print('== init ==')
print('== init ==', flush=True)
h = list(hosts.keys()) + ['%s.%s.' % (host, d) for host in hosts.keys()] + \
['%s.%s' % (host, d) for host in hosts.keys()] + list(hosts.values())
......@@ -206,7 +206,7 @@ if 'init' in args.actions:
perform_action('init', commands)
if 'wait' in args.actions:
print('== wait ==')
print('== wait ==', flush=True)
commands = [
['ansible', '-i', './inventory', '-m', 'command', '-a', 'uname -a', 'all'],
['ansible', '-i', './inventory', '-m', 'shell', '-a',
......@@ -215,7 +215,7 @@ if 'wait' in args.actions:
perform_action('wait', commands)
if 'deployment' in args.actions:
print('== deployment ==')
print('== deployment ==', flush=True)
commands = [
['ansible', '-i', './inventory', '-m', 'command', '-a', 'systemctl enable puppet-master',
'master'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment