def prepare_new(): '''Launch a new EC2 instance and install OBA requirements ''' # connect to AWS and launch new instance aws_conf = conf_helper.get_config('aws') oba_conf = conf_helper.get_config('oba') instance = launch_new_ec2(aws_conf) # Now that the status is running, it's not yet launched. # The only way to tell if it's fully up is to try to SSH in. aws_system = AwsFab(instance.public_dns_name, aws_conf) # If we've reached this point, the instance is up and running. print('SSH working') aws_system.update_system() aws_system.set_timezone(aws_conf.get('timezone')) aws_system.install_custom_monitoring() aws_system.turn_off_ipv6() aws_system.install_git() aws_system.install_jdk() aws_system.install_maven() aws_system.install_tomcat() aws_system.install_xwiki() # install pg init_sql_params = dict(pg_username=oba_conf.get('pg_username'), pg_password=oba_conf.get('pg_password'), pg_role=oba_conf.get('pg_role')) init_sql_filename = 'init.sql' init_sql_path = os.path.join(CONFIG_DIR, init_sql_filename) conf_helper.write_template(init_sql_params, init_sql_filename) aws_system.install_pg(init_sql_path, init_sql_filename) return instance
def centos6_test_battery(): # create config helper ConfHelper = ConfigHelper(CONFIG_DIR, TEMPLATE_DIR) # launch ec2 ec2_conf = ConfHelper.get_config('test_centos6') ec2_instance, ec2_connection = launch_new_ec2(ec2_conf, True) # do fab stuff to ec2 instance centos6_fab = CentOS6Fab(ec2_conf, ec2_instance.public_dns_name) centos6_fab.set_timezone('/usr/share/zoneinfo/America/Los_Angeles') centos6_fab.update_system() centos6_fab.install_helpers() centos6_fab.setup_iptables_for_port() centos6_fab.install_git() centos6_fab.install_jdk() centos6_fab.install_maven() centos6_fab.install_node() # pg setup init_sql_filename = 'init_test_db.sql' init_sql_path = os.path.join(TEMPLATE_DIR, init_sql_filename) centos6_fab.install_postgis('test_db', init_sql_path, init_sql_filename) # Terminate EC2 instance. tear_down(ec2_instance.id, ec2_connection)
def amazon_linux_test_battery(): # create config helper ConfHelper = ConfigHelper(CONFIG_DIR, TEMPLATE_DIR) # launch ec2 ec2_conf = ConfHelper.get_config('test_amazon_linux') ec2_instance, ec2_connection = launch_new_ec2(ec2_conf, True) # do fab stuff to ec2 instance amzn_linux_fab = AmazonLinuxFab(ec2_conf, ec2_instance.public_dns_name) amzn_linux_fab.set_timezone('/usr/share/zoneinfo/America/Los_Angeles') amzn_linux_fab.update_system() amzn_linux_fab.install_custom_monitoring() amzn_linux_fab.install_git() amzn_linux_fab.install_jdk() amzn_linux_fab.install_maven() amzn_linux_fab.install_node() # pg setup init_sql_filename = 'init_test_db.sql' init_sql_path = os.path.join(TEMPLATE_DIR, init_sql_filename) amzn_linux_fab.install_pg(init_sql_path, init_sql_filename) # Terminate EC2 instance. tear_down(ec2_instance.id, ec2_connection)
def setUp(self): '''Create a new EC2 instance.''' if not self.conf_type: raise Exception('Conf Path Must Be Set') ConfHelper = ConfigHelper(CONFIG_DIR, TEMPLATE_DIR) self.ec2_conf = ConfHelper.get_config(self.conf_type) ec2_instance, ec2_connection = launch_new_ec2(self.ec2_conf, True) self.ec2_instance = ec2_instance self.ec2_connection = ec2_connection
def deploy(): tear_down_on_error = False # launch ec2 ec2_conf = ConfHelper.get_config('aws') ec2_instance, ec2_connection = launch_new_ec2(ec2_conf, True) try: # do fab stuff to ec2 instance fab = OTVia2Fab(ec2_conf, ec2_instance.public_dns_name) fab.set_timezone('/usr/share/zoneinfo/America/Los_Angeles') fab.update_system() fab.install_custom_monitoring() fab.install_git() fab.install_node() fab.install_monitor() except: if tear_down_on_error: # Terminate EC2 instance. tear_down(ec2_instance.id, ec2_connection)