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

Launch final deployment

parent 36473f39
Branches master
No related tags found
No related merge requests found
...@@ -36,11 +36,17 @@ class ComponentHadoop: ...@@ -36,11 +36,17 @@ class ComponentHadoop:
with open('site2.pp', 'w') as f: with open('site2.pp', 'w') as f:
f.write(site) f.write(site)
def init_commands(self): def commands(self, action):
if action == 'init':
return [ return [
['ansible', '-i', './inventory', '-m', 'copy', '-a', 'src=site.pp dest=/root', 'all'], ['ansible', '-i', './inventory', '-m', 'copy', '-a', 'src=site.pp dest=/root', 'all'],
['ansible', '-i', './inventory', '-m', 'copy', '-a', 'src=site2.pp dest=/root', 'all'], ['ansible', '-i', './inventory', '-m', 'copy', '-a', 'src=site2.pp dest=/root', 'all'],
] ]
elif action == 'deployment':
return [
['ansible', '-i', './inventory', '-m', 'shell', '-a', 'puppet apply --test /root/site.pp >> stage1.log 2>&1; echo $?', 'all'],
['ansible', '-i', './inventory', '-m', 'shell', '-a', 'puppet apply --test /root/site2.pp >> stage2.log 2>&1; echo $?', 'all'],
]
class Component(ComponentHadoop): class Component(ComponentHadoop):
......
...@@ -8,7 +8,7 @@ import subprocess ...@@ -8,7 +8,7 @@ import subprocess
import sys import sys
import time import time
DEFAULT_ACTIONS = ['files', 'ping', 'init', 'wait'] DEFAULT_ACTIONS = ['files', 'ping', 'init', 'wait', 'deployment']
parser = argparse.ArgumentParser(description='terraform cluster orchestrator') parser = argparse.ArgumentParser(description='terraform cluster orchestrator')
parser.add_argument('-c', '--config', parser.add_argument('-c', '--config',
...@@ -110,7 +110,7 @@ if 'ping' in args.actions: ...@@ -110,7 +110,7 @@ if 'ping' in args.actions:
ret = subprocess.call(cmd) ret = subprocess.call(cmd)
time.sleep(2) time.sleep(2)
print('') print('')
print('-> sleep %d' % 10 + 5 * n) print('-> sleep %d' % (10 + 5 * n))
time.sleep(10 + 5 * n) time.sleep(10 + 5 * n)
if component: if component:
component.action('ping') component.action('ping')
...@@ -139,7 +139,7 @@ if 'init' in args.actions: ...@@ -139,7 +139,7 @@ if 'init' in args.actions:
['ansible', '-i', './inventory', '-m', 'copy', '-a', 'src=hosts dest=/etc/hosts', 'nodes'], ['ansible', '-i', './inventory', '-m', 'copy', '-a', 'src=hosts dest=/etc/hosts', 'nodes'],
] ]
if component: if component:
commands += component.init_commands() commands += component.commands('init')
for cmd in commands: for cmd in commands:
print('-> %s' % ' '.join(cmd)) print('-> %s' % ' '.join(cmd))
...@@ -163,3 +163,17 @@ if 'wait' in args.actions: ...@@ -163,3 +163,17 @@ if 'wait' in args.actions:
subprocess.run(cmd) subprocess.run(cmd)
if component: if component:
component.action('wait') component.action('wait')
if 'deployment' in args.actions:
print('== deployment ==')
commands = []
if component:
commands += component.commands('deployment')
for cmd in commands:
print('-> %s' % ' '.join(cmd))
if not args.dry_run:
subprocess.run(cmd)
if component:
component.action('deployment')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment