def create_webapp_instances(c, count, domain, security_groups, tags): tags["Role"] = "app-server" # Launch a vanilla amazon linux ami ec2_ids = launch_base_image(c, 1, security_groups, tags) print "New ID: ", ec2_ids new_id = ec2_ids[0] new_ami_id = None # Turn the EC2 instance into a viable app host extra_env = {"ANSIBLE_SERVICE_DOMAIN": domain} run_playbook_on_instances_by_ids(c, "aws_mess_around/playbooks/basics.yml", [new_id], extra_env) # XXX - this should be named based on the project/what-not! new_ami_id = create_ami_from_instance(c, new_id, MY_AMI_NAME, tags) # Launch webapp instances from the new ami we created. new_ids = launch_ami(c, new_ami_id, count, security_groups, tags) return new_ids
def create_proxy_instances(c, domain, count, security_groups, tags): tags["Role"] = "reverse-proxy" ec2_ids = launch_base_image(c, count, security_groups, tags) playbook = "aws_mess_around/playbooks/proxy/build_proxy.yml" run_playbook_on_instances_by_ids(c, playbook, ec2_ids) set_app_servers_for_proxies_by_id(c, domain, ec2_ids, []) return ec2_ids
def create_proxy_instances(c, domain, count, security_groups, tags): tags["Role"] = "reverse-proxy" ec2_ids = launch_base_image(c, count, security_groups, tags) playbook = "aws_mess_around/playbooks/proxy/build_proxy.yml" run_playbook_on_instances_by_ids( c, playbook, ec2_ids, ) set_app_servers_for_proxies_by_id(c, domain, ec2_ids, []) return ec2_ids
def create_db_instance(c, security_groups, tags, server_id): tags["Role"] = "database" ec2_ids = launch_base_image(c, 1, security_groups, tags) print "IDs: ", ec2_ids playbook = "aws_mess_around/playbooks/db/build_database.yml" password = generate_password() print "Setting root password: "******"ANSIBLE_MYSQL_ROOT": password, "ANSIBLE_MYSQL_SERVER_ID": "%s" % server_id } run_playbook_on_instances_by_ids(c, playbook, ec2_ids, env) return ec2_ids[0], password
def create_db_instance(c, security_groups, tags, server_id): tags["Role"] = "database" ec2_ids = launch_base_image(c, 1, security_groups, tags) print "IDs: ", ec2_ids playbook = "aws_mess_around/playbooks/db/build_database.yml" password = generate_password() print "Setting root password: "******"ANSIBLE_MYSQL_ROOT": password, "ANSIBLE_MYSQL_SERVER_ID": "%s" % server_id} run_playbook_on_instances_by_ids(c, playbook, ec2_ids, env) return ec2_ids[0], password