def deploy_ktb(self, ambari): if self.ostype.lower().startswith("centos") or self.ostype.lower().startswith("redhat"): ambari.run("yum -y install wget curl tar zip unzip gzip rsync") else: ambari.run("apt-get install -y wget curl tar zip unzip gzip rsync") ambari.run("mkdir -p /etc/kave/") ambari.run("echo http://repos:[email protected]/ >> /etc/kave/mirror") ambari.run("rm -rf inst.* ") import kavedeploy as lD lD.deploy_our_soft(ambari, self.version, repo="http://*****:*****@repos.dna.kpmglab.com", pack="kavetoolbox") return True
def deploy_ktb(self, ambari): if self.ostype.lower().startswith( "centos") or self.ostype.lower().startswith("redhat"): ambari.run("yum -y install wget curl tar zip unzip gzip rsync") else: ambari.run("apt-get install -y wget curl tar zip unzip gzip rsync") ambari.run("mkdir -p /etc/kave/") ambari.run( "echo http://repos:[email protected]/ >> /etc/kave/mirror" ) ambari.run("rm -rf inst.* ") import kavedeploy as lD lD.deploy_our_soft(ambari, self.version, repo="http://*****:*****@repos.dna.kpmglab.com", pack="kavetoolbox") return True
if __name__ == "__main__": ip, iid, security_conf, dest_type = parse_opts() # only needed in main function installfrom = os.path.realpath(os.sep.join(__file__.split(os.sep)[:-1])) liblocation = os.path.realpath(installfrom) jsondat = open(os.path.expanduser(security_conf)) security_config = json.loads(jsondat.read()) jsondat.close() sys.path.append(liblocation) import kavedeploy as lD import kaveaws as lA lA.checksecjson(security_config, requirefield=[], requirekeys=["SSH"]) if ip is None: lA.testaws() ip = lA.pub_ip(iid) git = False gitenv = None if lD.detect_proxy(): print "Did you already configure this machine to access port " + str( lD.proxy_port) + "? If not you'll need to turn your proxy off." lD.testproxy() remote = lD.remoteHost('root', ip, security_config["AccessKeys"]["SSH"]["KeyFile"]) if "GIT" in security_config["AccessKeys"]: git = True gitenv = security_config["AccessKeys"]["GIT"] lD.deploy_our_soft(remote, pack="kavetoolbox", git=git, gitenv=gitenv, options='--' + dest_type) # if dest_type == "workstation": # lD.confremotessh(remote)
################################################ # Try configuring password ################################################ import tempfile tempdir = '' try: tempdir = tempfile.mkdtemp() tempdir = tempdir + '/' fname = username + ip with open(tempdir + fname, 'w') as fp: fp.write(password + '\n') fp.write(password + '\n') remote.cp(tempdir + fname, fname) remote.run('cat ' + fname + ' | passwd ' + username) remote.run('rm -f ' + fname) except Exception as e: if os.path.exists(tempdir): os.system('rm -rf ' + tempdir) raise e ################################################ # Add KaveToolbox ################################################ lD.deploy_our_soft(remote, pack="kavetoolbox", version='3.0-Beta', options='--workstation') print "OK, iid " + iid + " now lives at IP " + ip remote.describe()
# #for conf in instancegroup["ExtraDisks"]: # # for instance in instancegroups[instancegroup["Name"]]: # # lA.add_new_ebs_vol(instance, conf, amazon_keyfile) print "==============================================" print "Add ambari to admin node" print "==============================================" sys.stdout.flush() for instancegroup in cluster_config["InstanceGroups"]: if instancegroup["AccessType"] == "admin": # print "found group", instancegroup["Name"] for instance in instancegroups[instancegroup["Name"]]: # lD.confremotessh(instance_to_remote[instance]) lD.deploy_our_soft(instance_to_remote[instance], git=git, gitenv=gitenv, pack="ambarikave", version=version) if "Tags" in security_config and vpcid: print "==============================================" print "Tag full VPC" print "==============================================" resources = lA.find_all_child_resources(vpcid) lA.tag_resources(resources, security_config["Tags"]) print "===================================" donedict = {} for instance, name in instance_to_name.iteritems(): donedict[name] = (instance, instance_to_remote[instance].host) print name,
remote.run('bash -c \'echo "' + username + ' ALL=(ALL:ALL) ALL" | (EDITOR="tee -a" visudo)\'') ################################################ # Try configuring password ################################################ import tempfile tempdir = '' try: tempdir = tempfile.mkdtemp() tempdir = tempdir + '/' fname = username + ip with open(tempdir + fname, 'w') as fp: fp.write(password + '\n') fp.write(password + '\n') remote.cp(tempdir + fname, fname) remote.run('cat ' + fname + ' | passwd ' + username) remote.run('rm -f ' + fname) except Exception as e: if os.path.exists(tempdir): os.system('rm -rf ' + tempdir) raise e ################################################ # Add KaveToolbox ################################################ lD.deploy_our_soft(remote, pack="kavetoolbox", version='3.6-Beta', options='--workstation') print "OK, iid " + iid + " now lives at IP " + ip remote.describe()
lA.add_ebs_volumes(adtoiids, admounts, amazon_keyfile) # #for conf in instancegroup["ExtraDisks"]: # # for instance in instancegroups[instancegroup["Name"]]: # # lA.add_new_ebs_vol(instance, conf, amazon_keyfile) # Fix permissions on /tmp allremotes.run("chmod 777 /tmp") print "==============================================" print "Add ambari to admin node" print "==============================================" sys.stdout.flush() for instancegroup in cluster_config["InstanceGroups"]: if instancegroup["AccessType"] == "admin": # print "found group", instancegroup["Name"] for instance in instancegroups[instancegroup["Name"]]: # lD.confremotessh(instance_to_remote[instance]) lD.deploy_our_soft(instance_to_remote[instance], git=git, gitenv=gitenv, pack="ambarikave", version=version) if "Tags" in security_config and vpcid: print "==============================================" print "Tag full VPC" print "==============================================" resources = lA.find_all_child_resources(vpcid) lA.tag_resources(resources, security_config["Tags"]) print "===================================" donedict = {} for instance, name in instance_to_name.iteritems(): donedict[name] = (instance, instance_to_remote[instance].host) print name, instance_to_remote[instance].describe() print "Complete, created:", donedict
print "OK, iid " + iid + " now lives at IP " + ip ip = "" remote = "" if (not skip_ambari) or (not skip_blueprint): ip = lA.pub_ip(iid) remote = lD.remoteHost('root', ip, keyloc) lD.configure_keyless(remote, remote, lA.priv_ip(iid), preservehostname=True) # # # INSTALL AMBARI HEAD and Deploy a very simple default blueprint! # # if not skip_ambari: print "Installing ambari " + version + " from git" lD.deploy_our_soft(remote, version=version, git=git, gitenv=gitenv) print "Awaiting ambari installation ..." lD.wait_for_ambari(remote, check_inst=['inst.stderr', 'inst.stdout']) if not skip_blueprint: print "Deploying default blueprint" stdout = lD.run_quiet( base + "/../deploy_from_blueprint.py --not-strict " + base + "/../blueprints/default.blueprint.json " + base + "/../blueprints/default.cluster.json " + remote.host + " " + secf) print stdout print "Awaiting blueprint completion" lD.waitforrequest(remote, 'default', 1) # # # Stop the instance and create an image from it!
liblocation = os.path.realpath(installfrom) jsondat = open(os.path.expanduser(security_conf)) security_config = json.loads(jsondat.read()) jsondat.close() sys.path.append(liblocation) import kavedeploy as lD import kaveaws as lA lA.checksecjson(security_config, requirefield=[], requirekeys=["SSH"]) if ip is None: lA.testaws() ip = lA.pub_ip(iid) git = False gitenv = None if lD.detect_proxy(): print "Did you already configure this machine to access port " + str( lD.proxy_port) + "? If not you'll need to turn your proxy off." lD.testproxy() remote = lD.remoteHost('root', ip, security_config["AccessKeys"]["SSH"]["KeyFile"]) if "GIT" in security_config["AccessKeys"]: git = True gitenv = security_config["AccessKeys"]["GIT"] lD.deploy_our_soft(remote, pack="kavetoolbox", git=git, gitenv=gitenv, options='--' + dest_type) # if dest_type == "workstation": # lD.confremotessh(remote)
if __name__ == "__main__": ip, iid, security_conf, dest_type = parse_opts() # only needed in main function installfrom = os.path.realpath(os.sep.join(__file__.split(os.sep)[:-1])) liblocation = os.path.realpath(installfrom) jsondat = open(os.path.expanduser(security_conf)) security_config = json.loads(jsondat.read()) jsondat.close() sys.path.append(liblocation) import kavedeploy as lD import kaveaws as lA lA.checksecjson(security_config, requirefield=[], requirekeys=["SSH"]) if ip is None: lA.testaws() ip = lA.pub_ip(iid) git = False gitenv = None if lD.detect_proxy(): print "Did you already configure this machine to access port " + str( lD.proxy_port) + "? If not you'll need to turn your proxy off." lD.testproxy() remote = lD.remoteHost('root', ip, security_config["AccessKeys"]["SSH"]["KeyFile"]) if "GIT" in security_config["AccessKeys"]: git = True gitenv = security_config["AccessKeys"]["GIT"] lD.deploy_our_soft(remote, pack="kavetoolbox", git=git, gitenv=gitenv) # if dest_type == "workstation": # lD.confremotessh(remote)