Git Product home page Git Product logo

ansible-cassandra's Introduction

ansible-cassandra

Ansible role to install an Apache Cassandra cluster supervised by systemd. Includes the following:

  • Some OS tuning options such as installing jemalloc, setting max_map_count and tcp_keepalive, disabling swap.
  • Bootstraps nodes using the IPs of the servers in the cassandra_seed (configurable) inventory group.
  • Weekly scheduled repairs via cron jobs that are non-overlapping (see cassandra_repair_slots).
    • Note that all keyspaces will be scheduled for repairs
  • Incremental and full backup scripts as well as a restore script. (disabled by default, optional) (NOTE: needs better testing)
    • backup/restore requires access to S3.
  • prometheus-style metrics using jmx-exporter

Status: beta, see TODOs

Build Status

Ansible Requirements

  • ansible >= 2.4 (>= 2.7.9 recommended)

Role Variables

Give your cluster a better name:

# set cassandra_cluster_name before running the playbook for the first time; never change it afterwards
cassandra_cluster_name: default

You may wish to override the following defaults to enable backups:

# backups
cassandra_backup_enabled: false # recommended to enable this
cassandra_incremental_backup_enabled: false # enable for built-in incremental backup routine
cassandra_backup_s3_bucket: # set a name here and ensure hosts have access rights to an S3 bucket
cassandra_env: dev # used in naming backups in case you have more than one environment (e.g. production, staging, ...)

For a list of all variables, see defaults/main.yml.

Dependencies

The following should be installed before installing this role:

For the above dependencies, you can use the same roles as in molecule/default/requirements.yml - but you don't have to.

Platforms

Example Playbook

Assuming an inventory with 5 nodes where you wish to install cassandra on, two of them seed nodes:

# hosts.ini
[all]
host01 ansible_host=<some IP>
host02 ansible_host=<some IP>
host03 ansible_host=<some IP>
host04 ansible_host=<some IP>
host05 ansible_host=<some IP>

[cassandra]
host01
host02
host03
host04
host05

# cassandra_seed group will be used to configure seed bootstrapping
# recommended is 2 seed nodes per datacenter
[cassandra_seed]
host01
host02

Then the following should work and start your cluster:

# playbook.yml

- hosts: cassandra
  vars:
    # set cluster_name before running the playbook for the first time; never change it afterwards
    cassandra_cluster_name: my_cluster
    # set installed java package version manually. required when using Ubuntu 18.04. see: [A note on Java 8 and Ubuntu 18.04](#a-note-on-Java-8-and-Ubuntu-18.04)
    java_packages: openjdk-8-jdk
  roles:
    # ensure to install java and ntp first, e.g. by running these roles (see Dependencies section):
    # - ansible-ntp
    # - ansible-role-java
    - ansible-cassandra

If you don't wish to configure cassandra seed nodes via a cassandra_seed_groupname (default: cassandra_seed) inventory group, you can configure them statically:

  vars:
    cassandra_seed_resolution: static
    cassandra_seeds:
      - 1.2.3.4
      - ...

License

AGPL. See LICENSE

A note on openjdk vs oracle:

As of November 2018, the cassandra homepage lists both openJDK and Oracle Java as supported (and offers their download links).

In the official upgrade-to-DSE docs one can find:

Important: Although Oracle JRE/JDK 8 is supported, DataStax does more extensive testing on OpenJDK 8 starting with DSE 6.0.3. This change is due to the end of public updates for Oracle JRE/JDK 8.)

It seems OpenJDK is the more future-proof JVM to use. This role is tested using openjdk.

A note on Java 8 and Ubuntu 18.04:

In order to deploy Java on Ubuntu using Ansible, we have been using the 'ansible-role-java' role. This role will install OpenJDK 11 on Ubuntu 18.04 by default. If you are using this role, it is required to set the 'java_packages' variable before running it. for example:

# set the java packages installed by the ansible-role-java role manually.
java_packages: openjdk-8-jdk

Development setup

Install molecule. E.g. ensure you have docker installed, then, using a virtualenv, pip install molecule ansible docker.

  • molecule converge to run the playbook against docker containers. If something fails, molecule --debug converge shows error details.
  • molecule lint and molecule syntax can be used to get feedback on your yaml changes.
  • molecule test to destroy + converge + converge again for idempotence + destroy

If you want 'mocule converge' to be run each time you save a file in this repository, install entr, then run 'make'.

  • troubleshooting: this issue has been observed with molecule, ansible 2.7 and docker. Workaround was to downgrade to ansible 2.5.

Credits

This role has been inspired by

  • internal role used at Wire initially targeting older OSes and older cassandra versions.
  • this cassandra role and its dependent roles (insufficient for our needs)

TODO

  • WARN: JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.
  • test backups and restore
  • document usage of prometheus .prom files and node-exporter
  • check out if instead of cron jobs a repair alternative could be https://github.com/thelastpickle/cassandra-reaper

ansible-cassandra's People

Contributors

amitsagtani97 avatar fisx avatar jschaul avatar jschumacher-wire avatar julialongtin avatar lucendio avatar neolemarc avatar tiago-loureiro avatar veki301 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-cassandra's Issues

Notes when upgrading to ubuntu 18

This ansible role has been tested on ubuntu 16, but it'd be useful to already have some ideas on what may/will break with ubuntu 18. This is the feedback from one user:

roles-external/ansible-role-java/vars/Ubuntu-18.yml

  • openjdk-11-jdk
    =>
  • openjdk-8-jdk
    (servers are Ubuntu 18.04, and Cassandra 3.11 is only compatible with Java 8)

No package matching 'libjemalloc1' is available

{"ansible_loop_var": "item", "changed": false, "item": "libjemalloc1", "msg": "No package matching 'libjemalloc1' is available"}

libjemalloc1 is not available for Ubuntu 21.10.
Try to use libjemalloc2

Ansible role fails with undefined variable

Hi

I have been using the ansible cassandra role you have setup. Thank you for this.

I have been having issues with the build however.

TASK [ansible-cassandra : download prometheus jmx exporter jar] ******************************************************************************************
ok: [perf108]
ok: [perf109]
ok: [perf110]

TASK [ansible-cassandra : prometheus jmx config] *********************************************************************************************************
ok: [perf109]
ok: [perf108]
ok: [perf110]

TASK [ansible-cassandra : main configuration (cassandra.yaml)] *******************************************************************************************
fatal: [perf108]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute u'ansible_ens192'"}
fatal: [perf109]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute u'ansible_ens192'"}
fatal: [perf110]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' has no attribute u'ansible_ens192'"}

when i run the ansible setup module I do see

        "ansible_default_ipv4": {
            "address": "x.x.x.108", 
            "alias": "ens192", 
            "broadcast": "x.x.x.255", 
            "gateway": "x.x.x.254", 
            "interface": "ens192", 
            "macaddress": "00:50:56:aa:dd:ee", 
            "mtu": 1500, 
            "netmask": "255.255.255.0", 
            "network": "x.x.x.0", 
            "type": "ether"
        }, 


        "ansible_ens192": {
            "active": true, 
            "device": "ens192", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "on", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "on", 
                "loopback": "off [fixed]", 
                "netns_local": "off [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "on", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "on", 
                "rx_fcs": "off [fixed]", 
                "rx_gro_hw": "off [fixed]", 
                "rx_udp_tunnel_port_offload": "off [fixed]", 
                "rx_vlan_filter": "on [fixed]", 
                "rx_vlan_offload": "on", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "on", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "off [fixed]", 
                "tx_gre_csum_segmentation": "off [fixed]", 
                "tx_gre_segmentation": "off [fixed]", 
                "tx_gso_partial": "off [fixed]", 
                "tx_gso_robust": "off [fixed]", 
                "tx_ipip_segmentation": "off [fixed]", 
                "tx_lockless": "off [fixed]", 
                "tx_nocache_copy": "off", 
                "tx_scatter_gather": "on", 
                "tx_scatter_gather_fraglist": "off [fixed]", 
                "tx_sctp_segmentation": "off [fixed]", 
                "tx_sit_segmentation": "off [fixed]", 
                "tx_tcp6_segmentation": "on", 
                "tx_tcp_ecn_segmentation": "off [fixed]", 
                "tx_tcp_mangleid_segmentation": "off", 
                "tx_tcp_segmentation": "on", 
                "tx_udp_tnl_csum_segmentation": "off [fixed]", 
                "tx_udp_tnl_segmentation": "off [fixed]", 
                "tx_vlan_offload": "on", 
                "tx_vlan_stag_hw_insert": "off [fixed]", 
                "udp_fragmentation_offload": "off [fixed]", 
                "vlan_challenged": "off [fixed]"
            }, 

Can you please advise what would I need to do to have the script working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.