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

Poor-man implementation of waiting

parent 90e74c82
No related branches found
No related tags found
No related merge requests found
#! /bin/sh -xe #! /bin/sh -xe
./terraform apply -auto-approve "$@" ./terraform apply -auto-approve "$@"
./terraform output -json > config.json ./terraform output -json > config.json
echo 'Sleeping...'
sleep 60
echo "Press <ENTER> to continue..."
read x
./orchestrate.py -c config.json ./orchestrate.py -c config.json
...@@ -6,8 +6,9 @@ import json ...@@ -6,8 +6,9 @@ import json
import os import os
import subprocess import subprocess
import sys import sys
import time
DEFAULT_ACTIONS = ['files', 'init', 'check'] DEFAULT_ACTIONS = ['files', 'ping', 'init', 'wait']
parser = argparse.ArgumentParser(description='terraform cluster orchestrator') parser = argparse.ArgumentParser(description='terraform cluster orchestrator')
parser.add_argument('-c', '--config', parser.add_argument('-c', '--config',
...@@ -89,6 +90,31 @@ ff02::2 ip6-allrouters ...@@ -89,6 +90,31 @@ ff02::2 ip6-allrouters
if component: if component:
component.action('files') component.action('files')
if 'ping' in args.actions:
print('== ping ==')
if not args.dry_run:
print('-> (ping) ', end='')
ret = None
while ret is None or ret != 0:
print('.', end='')
ret = subprocess.call(['ping', '-c', '1', '-i', '2', master_ip])
print('')
cmd = ['ssh-keygen', '-R', master_ip]
print('-> %s' % ' '.join(cmd))
subprocess.run(cmd)
cmd = ['ssh', '%s@%s' % (user, master_ip), '-o', 'ConnectTimeout=5', '-o',
'StrictHostKeyChecking=no', ':']
ret = None
while ret is None or ret != 0:
print('-> %s' % ' '.join(cmd))
ret = subprocess.call(cmd)
time.sleep(2)
print('')
print('-> sleep %d' % 10 + 5 * n)
time.sleep(10 + 5 * n)
if component:
component.action('ping')
if 'init' in args.actions: if 'init' in args.actions:
print('== init ==') print('== init ==')
...@@ -122,11 +148,13 @@ if 'init' in args.actions: ...@@ -122,11 +148,13 @@ if 'init' in args.actions:
if component: if component:
component.action('init') component.action('init')
if 'check' in args.actions: if 'wait' in args.actions:
print('== check ==') print('== wait ==')
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',
'while ! test -f /var/lib/cloud/instance/boot-finished; do sleep 2; done', 'all'],
] ]
for cmd in commands: for cmd in commands:
...@@ -134,4 +162,4 @@ if 'check' in args.actions: ...@@ -134,4 +162,4 @@ if 'check' in args.actions:
if not args.dry_run: if not args.dry_run:
subprocess.run(cmd) subprocess.run(cmd)
if component: if component:
component.action('check') component.action('wait')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment