Unverified Commit afdf67ad by Kevin Falcone Committed by GitHub

Merge pull request #4685 from edx/jibsheet/create_rds

A new playbook to create RDSes
parents 7923a2cf 93056a9b
# This play will create an RDS for an application.
# It can be run like so:
#
# ansible-playbook -c local -i 'localhost,' create_rds.yml -e@./db.yml
#
# where the content of db.yml contains the following settings
#
# It can read from the same config as create_dbs_and_users.yml and needs this
# part of that config
# database_connection:
# login_user: "root"
# login_password: "super-secure-password"
#
# database_name: your-database-name
# database_size: number of gigabytes (integer)
# instance_type: Choose an AWS RDS instance type such as "db.t2.medium"
# aws_region: a full region (such as us-east-1 or us-west-2) not an AZ
# database_engine_version: You should use either or standard or the newest possible, such as "5.6.39"
# maintenance_window: UTC time and day of week to allow maintenance "Mon:16:00-Mon:16:30"
# vpc_security_groups: What security group in the VPC your RDS should belong to (this is separate from your app or elb SG)
# subnet_group: a name of a group in the RDS console that contains subnets, it will pick the appropriate one
# parameter_group: name of the parameter group with overriddent defaults for this RDS
# backup_window: UTC time of the day to take a backup "08:00-08:30"
# backup_retention: Days to keep backups (integer)
# multi_zone: yes or no (whether this RDS is multi-az)
# tags:
# environment: "environment"
# deployment: "deployment"
# cluster: "cluster"
- name: Create databases and users
hosts: all
gather_facts: False
tasks:
- name: create RDS
rds:
command: create
instance_name: "{{ database_name }}"
db_engine: "{{ database_engine|default('MySQL') }}"
size: "{{ database_size }}"
instance_type: "{{ instance_type }}"
region: "{{ aws_region }}"
username: "{{ database_connection.login_user }}"
password: "{{ database_connection.login_password }}"
engine_version: "{{ database_engine_version }}"
maint_window: "{{ maintenance_window }}"
multi_zone: "{{ multi_zone }}"
vpc_security_groups: "{{ vpc_security_groups }}"
subnet: "{{ subnet_group }}"
parameter_group: "{{ parameter_group }}"
backup_window: "{{ backup_window }}"
backup_retention: "{{ backup_retention }}"
tags: "{{ tags }}"
# It would be nice to wait for success, but this takes a while and I routinely tripped
# the API call limit at AWS. Add it back if we know how to limit those.
# wait: yes
# wait_timeout: 900
# Usage: AWS_PROFILE=myprofile ansible-playbook create_csmh_db.yml -i localhost, -e 'from_db=my-rds-identifier rds_name=env-dep-edxapphistory'
- name: Create new edxapp history RDS instance
hosts: all
connection: local
gather_facts: false
vars:
from_db: null
rds_name: null
region: us-east-1
instance_type: db.m4.large
env: null
app: edxapp
tasks:
- name: Validate arguments
fail:
msg: "One or more arguments were not set correctly: {{ item }}"
when: not item
with_items:
- from_db
- rds_name
- name: Create edxapp history RDS instance
rds:
command: replicate
instance_name: "{{ rds_name }}"
source_instance: "{{ from_db }}"
region: "{{ region }}"
instance_type: "{{ instance_type }}"
publicly_accessible: no
wait: yes
wait_timeout: 900
register: created_db
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment