Commit ea990283 by Max Rothman

Merge pull request #2005 from edx/max/cassandra

Add cassandra role
parents 8b868324 7a44e50b
---
cassandra_version: "2.0.14"
# AFAIK there's no way to detect instance storage after the instaces has started.
# Therefore, you MUST know the device names ahead of time.
# If this is empty, no disks will be mounted and data will be put on the root volume.
cassandra_ephemeral_disks: []
#cassandra_ephemeral_disks: ["/dev/xvdb", "/dev/xvdc"]
cassandra_data_dir_prefix: /var/lib/cassandra/data
#should be parallel to cassandra_ephemeral_disks if there are any
cassandra_data_dirs: ["data.1"]
#These are set by the package. Don't change them!
cassandra_user: "cassandra"
cassandra_group: "cassandra"
# cassandra.yaml basic configuration parameters
cassandra_cluster_name: "Test Cluster"
#Set this unless you want your node to only listen locally.
cassandra_seeds: ["127.0.0.1"]
#should eventually use EC2Snitch
cassandra_snitch: "SimpleSnitch"
#set this ONLY when initializing a new cluster with NO DATA
cassandra_auto_bootstrap: false
# For single-node locally-accessible deployments only! Otherwise, use:
# cassandra_listen_address: ""
cassandra_listen_address: localhost
\ No newline at end of file
---
dependencies:
- common
- oraclejdk
\ No newline at end of file
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role cassandra
#
# Overview:
#
# This role sets up a cassandra node.
- name: Unmount disks mounted to the wrong place
mount:
name: "{{ item[0].mount }}"
src: "{{ item[0].device }}"
fstype: "{{ item[0].fstype }}"
state: unmounted
when: item[1] == item[0].device and not item[0].mount.startswith(cassandra_data_dir_prefix)
with_nested:
- ansible_mounts
- cassandra_ephemeral_disks
- name: Create data directories
file:
path: "{{ cassandra_data_dir_prefix }}/{{ item }}"
state: directory
with_items: cassandra_data_dirs
- name: Mount ephemeral disks
mount:
name: "{{ cassandra_data_dir_prefix }}/{{ item.1 }}"
src: "{{ item.0 }}"
fstype: ext4
state: mounted
with_together:
- cassandra_ephemeral_disks
- cassandra_data_dirs
when: cassandra_ephemeral_disks
#Mounting a disk overlays its permissions
- name: Set permissions on data dirs
file:
path: "{{ cassandra_data_dir_prefix }}/{{ item }}"
owner: "{{ cassandra_user }}"
group: "{{ cassandra_group }}"
with_items: cassandra_data_dirs
- name: Add the datastax repository apt-key
apt_key:
url: "http://debian.datastax.com/debian/repo_key"
state: present
- name: Add the datastax repository
apt_repository:
repo: "deb http://debian.datastax.com/community stable main"
state: present
- name: Install the cassandra package
apt:
name: "cassandra={{ cassandra_version }}"
state: present
update_cache: yes
- name: Update the cassandra configuration
template:
src: "{{item}}.j2"
dest: /etc/cassandra/{{item}}
owner: "{{cassandra_user}}"
group: "{{cassandra_group}}"
mode: 0644
with_items:
- "cassandra-env.sh"
- "cassandra.yaml"
- name: restart cassandra
service:
name: cassandra
state: restarted
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