Various fixes to the cluster script.

This commit is contained in:
Tim Kuhlman 2014-05-21 15:24:36 -06:00
parent 857fc969a6
commit b536e89bf5
3 changed files with 23 additions and 10 deletions

View File

@ -51,7 +51,7 @@ data_bag_path "{dir}/data_bags"'''.format(dir=chef_dir)
@task
def git_mini_mon(install_dir, proxy=None):
def git_mini_mon(install_dir, branch=None, proxy=None):
"""Download mini-mon from git
"""
with prefix(proxy_string(proxy)):
@ -61,10 +61,14 @@ def git_mini_mon(install_dir, proxy=None):
if install_dir_check.succeeded:
with cd(install_dir):
sudo('git pull -f origin master')
sudo('git checkout master; git pull -f origin master')
else:
sudo('git clone https://github.com/hpcloud-mon/mon-vagrant.git %s' % install_dir)
if branch is not None:
with cd(install_dir):
sudo('git checkout %s' % branch)
@task(default=True)
def install(install_dir='/vagrant', proxy=None):
"""Installs the latest mini-mon and bits necessary to run chef-solo and runs chef-solo on the box.

View File

@ -17,4 +17,3 @@ The goal of this fabric script is to setup a test cluster on baremetal leveragin
- Setup the Vertica database schema
- Setup the mysql database schema
- Restart any services which require vertica or mysql

View File

@ -19,6 +19,7 @@ These tasks were developed for hLinux but will likely work on any decently up to
"""
from fabric.api import *
from fabric.tasks import Task
import os
from baremetal import chef_solo, git_mini_mon, install_deps
@ -34,6 +35,7 @@ class SetupCluster(Task):
self.cluster_dir = '/var/tmp/chef-Mon-Node'
self.cluster_hosts = None
self.mini_mon_dir = '/vagrant' # mini_mon_dir is /vagrant to match assumptions in mini-mon
self.vertica_packages = ['vertica_7.0.1-0_amd64.deb', 'vertica-r-lang_7.0.1-0_amd64.deb']
def run(self):
"""Installs the latest cookbooks and dependencies to run chef-solo and runs chef-solo on each box.
@ -42,18 +44,26 @@ class SetupCluster(Task):
self.cluster_hosts = env.hosts
execute(install_deps)
execute(git_mini_mon, self.mini_mon_dir)
execute(git_mini_mon, self.mini_mon_dir, 'feature/cluster')
# download cookbooks
with cd(self.cluster_dir):
sudo('berks vendor')
with settings(hide('running', 'output', 'warnings'), warn_only=True):
sudo('rm -r %s' % self.cluster_dir)
sudo('mkdir %s' % self.cluster_dir)
with cd(self.mini_mon_dir):
sudo('berks vendor %s/berks-cookbooks' % self.cluster_dir)
# the vertica packages from my.vertica.com are needed, this assumes they are one level up from cwd
put('../vertica*.deb', self.mini_mon_dir, use_sudo=True)
for deb in self.vertica_packages:
with settings(hide('running', 'output', 'warnings'), warn_only=True):
if run('ls %s/%s' %(self.mini_mon_dir, deb)).failed:
puts('Uploading %s' % deb)
put('../../vertica*.deb', self.mini_mon_dir, use_sudo=True)
# Copy roles and data bags
put('%s/utils/cluster/data_bags' % self.mini_mon_dir, self.cluster_dir, use_sudo=True)
put('%s/utils/cluster/roles' % self.mini_mon_dir, self.cluster_dir, use_sudo=True)
# Copy roles and data bags - assumes you are running from the utils directory
put('%s/cluster/data_bags' % os.path.dirname(env.real_fabfile), self.cluster_dir, use_sudo=True)
put('%s/cluster/roles' % os.path.dirname(env.real_fabfile), self.cluster_dir, use_sudo=True)
execute(chef_solo, self.cluster_dir, "role[Mon-Node]")