Skip to content

Instantly share code, notes, and snippets.

@tzach
Created July 19, 2016 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzach/31ba083bcf587cdcb20c85c258e5def0 to your computer and use it in GitHub Desktop.
Save tzach/31ba083bcf587cdcb20c85c258e5def0 to your computer and use it in GitHub Desktop.
Ansible playbook to start a Scylla cluster, with 10 EBS attached to each node
## This Ansible script start a cluster of 3 nodes on EC2
## And attach 10 ESB, 100G each
- name: Provision voulums
hosts: localhost
connection: local
vars:
region: us-east-1
cluster_nodes: 3
user_data: "--clustername test-cluster --totalnodes {{cluster_nodes}}"
tasks:
- name: create instance
local_action:
module: ec2
wait: yes
keypair: "tzach-test-and-deploy-key" ## Use your own key!
image: "ami-dd46ffca" ## Scylla 1.2.1 AMI
assign_public_ip: yes
instance_type: "c3.8xlarge"
count: "{{cluster_nodes}}"
user_data: "{{user_data}}"
region: "{{region}}"
group: cassandra-security-group ## Use your own group!
vpc_subnet_id: "subnet-ec4a72c4" ## Use your own subnet!
instance_tags:
Name: "Tzach EBS test" ## Use your own name ;)
register: ec2
- add_host: hostname={{ item.public_ip }} groupname=NewDB
with_items: ec2.instances
- name: create volume
local_action:
module: ec2_vol
instance: "{{item[0].id}}"
region: "{{region}}"
volume_type: gp2
volume_size: 100
device_name: "{{item[1]}}"
register: ec2_vol
with_nested:
- ec2.instances
- [ '/dev/xvdf', '/dev/xvdg', '/dev/xvdh', '/dev/xvdi', '/dev/xvdj', '/dev/xvdk', '/dev/xvdl', '/dev/xvdm', '/dev/xvdn', '/dev/xvdo' ]
- debug: msg="{{ec2_vol}}"
- name: tag a resource
local_action:
module: ec2_tag
region: "{{region}}"
resource: "{{item.volume_id}}"
state: present
tags:
Name: "tzach" ## Use your own name again!
use: "data"
with_items: ec2_vol.results
- name: Wait for SSH to come up
wait_for: host={{item.public_ip}} port=22 delay=60 timeout=600 state=started
with_items: ec2.instances
- name: Prepare scylla nodes
hosts: NewDB
user: "centos"
tasks:
- name: restart scylla service
service: name=scylla-server state=stopped
sudo: yes
## This part cancel the RAID setup done by Scylla AMI setup, and run it again on the new ESBs
- command: 'umount /var/lib/scylla'
sudo: yes
- command: 'mdadm --stop md0'
sudo: yes
- command: 'scylla_raid_setup --disks /dev/xvdf,/dev/xvdg,/dev/xvdh,/dev/xvdi,/dev/xvdj,/dev/xvdk,/dev/xvdl,/dev/xvdm,/dev/xvdn,/dev/xvdo --update-fstab'
sudo: yes
- debug: msg="starting scylla_io_setup, this part can take long minutes!"
- command: '/usr/sbin/scylla_io_setup'
sudo: yes
- name: restart scylla service
service: name=scylla-server state=started
sudo: yes
- name: restart jmx service
service: name=scylla-jmx state=started
sudo: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment