Commit c551d6b7 by Max Rothman

OPS-563: Add cassandra role

parent 350022bf
The MIT License
Copyright (c) 2014 Pieterjan Vandaele
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Heavily modified from...
## ANXS - cassandra
Ansible role which installs and configures Apache Cassandra.
#### License
This directory is licensed under the MIT License. See the LICENSE file for details.
cassandra_version: "2.0.14"
cassandra_source_url: "http://archive.apache.org/dist/cassandra/{{cassandra_version}}/apache-cassandra-{{cassandra_version}}-bin.tar.gz"
# AFAIK there's no way to detect instance storage after the instaces has started.
# Therefore, you MUST know the device names ahead of time.
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"]
cassandra_user: "cassandra"
cassandra_group: "cassandra"
cassandra_home: "{{ COMMON_APP_DIR }}/{{cassandra_user}}"
# cassandra.yaml basic configuration parameters
cassandra_cluster_name: "Test Cluster"
#Set this!
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: true
# For single-node locally-accessible deployments only! Otherwise, use:
# cassandra_listen_address: ""
cassandra_listen_address: localhost
\ No newline at end of file
# file: cassandra/meta/main.yml
dependencies:
- common
- oraclejdk
\ No newline at end of file
- name: Make sure the cassandra group is present
group:
name: "{{cassandra_group}}"
state: present
- name: Make sure the cassandra user is present
user:
name: "{{cassandra_user}}"
group: "{{cassandra_group}}"
home: "{{cassandra_home}}"
createhome: yes
shell: /bin/false
- name: Make sure the cassandra user home has correct permissions
file:
path: "{{cassandra_home}}"
owner: "{{cassandra_user}}"
group: "{{cassandra_group}}"
- 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