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