locp.cassandra

ansible-role-cassandra

Gitter CI

Ansible role to install and set up Apache Cassandra.

Requirements

OS Family Identification

The Ansible playbook must gather enough details so that the ansible_os_family variable can be set.

Python Modules

For Debian systems, if cassandra_configure_apache_repo is set to True, note that the apt_repository module is used. This means you need to have the following on the host running this module:

  • python-apt (for Python 2)
  • python3-apt (for Python 3)

Role Variables

  • cassandra_15770_workaround: (default: False) This applies a fix for issues affecting Debian 10 and Ubuntu 20.04, relating to CASSANDRA-15770. It will adjust /etc/init.d/cassandra if set to True.

  • cassandra_2356_workaround: (default: False) This addresses issues with Debian packages for Cassandra versions before 4.0 relating to CASSANDRA-2356.

  • cassandra_cms_heap_new_size_mb: This provides a value (in MB) to set the HEAP_NEWSIZE for the Concurrent Mark Sweep (CMS) Collector. More info in Tuning Java resources. Requires cassandra_memtotal_mb and cassandra_processor_vcpus to be set.

  • cassandra_cms_max_heapsize_mb: This provides a value (in MB) to set the MAX_HEAP_SIZE for the CMS Collector. See Tuning Java resources for details. Requires cassandra_memtotal_mb.

  • cassandra_configuration (default: none): The configuration settings for Cassandra. Check the example playbook below for details.

  • cassandra_configuration_directory (default: /etc/cassandra/default.conf on RedHat and /etc/cassandra on Debian): The directory where Cassandra configuration files are located.

  • cassandra_configuration_file (default: /etc/cassandra/default.conf/cassandra.yaml on RedHat and /etc/cassandra/cassandra.yaml on Debian): The file path for the Cassandra configuration settings.

  • cassandra_configuration_templ (default: cassandra.yaml.j2): The name of the template file for Cassandra configuration.

  • cassandra_configure_apache_repo (default: False): Specify whether to set up the Apache Cassandra repository.

    SEE ALSO: cassandra_repo_apache_release.

  • cassandra_dc: If specified, this sets the Datacenter in cassandra-rackdc.properties. This option will be removed in the future. Use cassandra_regex_replacements instead.

  • cassandra_directories: If specified, this will create directories after the package is installed (when the Cassandra user is active) but before configuring Cassandra. See the example playbook for details.

    Note: If used with cassandra_join_cluster, the paths here will be deleted and recreated for the node to join the cluster properly.

  • cassandra_heap_new_size_mb: A value (in MB) for HEAP_NEWSIZE. More details in Tuning Java resources. Requires cassandra_memtotal_mb and cassandra_processor_vcpus.

  • cassandra_install_packages (default: True): A boolean to indicate if the role should try to install packages. If set to False, it allows configuring Cassandra without installation (e.g., if installed from source).

  • cassandra_join_cluster (default: False): An experimental feature; use cautiously! If true and cassandra_node_count is 1, it will stop Cassandra, clear data directories, and then reconfigure the node to join a larger cluster.

  • cassandra_max_heapsize_mb: A value (in MB) for MAX_HEAP_SIZE. More details are in Tuning Java resources. Requires cassandra_memtotal_mb.

  • cassandra_memtotal_mb (default: ansible_memtotal_mb if set): Used to calculate the heap sizes mentioned above.

  • cassandra_path This variable was introduced in version 1.4.0 but was not documented. If defined and deleted, it won’t be recreated. It is now deprecated in favor of cassandra_directories.

  • cassandra_node_count: A read-only variable that keeps track of the number of nodes in the cluster. It will be set only if cassandra_join_cluster is true.

  • cassandra_package (default: cassandra): The name of the package needed to install Cassandra.

  • cassandra_processor_vcpus (default: ansible_processor_vcpus if set): Used to calculate the heap sizes mentioned before.

  • cassandra_rack: If specified, this sets the rack in cassandra-rackdc.properties. This option will be removed in future releases. Use cassandra_regex_replacements instead.

  • cassandra_regex_replacements (default: []): A list detailing a path relative to cassandra_configuration_directory, regexp to find in a file, and line for the replacement. See the example playbook for more information.

  • cassandra_repo_apache_release (default: None): Specifies the release series (can be 40x, 311x, or 30x). This must be set if cassandra_configure_apache_repo is true.

  • cassandra_service_enabled (default: yes): Specify if the Cassandra service should be enabled (yes or no).

  • cassandra_service_restart (default: True): If true, changes to the Cassandra configuration or data directories will refresh the service after alterations.

  • cassandra_systemd_enabled (default: False): Should the Cassandra service be enabled through systemd? If true, a unit file will be created from the template when enabled.

  • cassandra_systemd_path (default: /usr/lib/systemd/system/cassandra.service): The path to the unit file for Cassandra. This is ignored if cassandra_systemd_enabled is False.

  • cassandra_systemd_template (default: "systemd/system/cassandra.service.j2"): The template path for creating the unit file for Cassandra. This is ignored if cassandra_systemd_enabled is False.

  • cassandra_task_delay (default: 10): Allows Ansible tasks that need network access (like apt and yum) to retry in case of delays. This is the waiting time between retries.

  • cassandra_task_retries (default: 5): The number of retries for network-related tasks if there are delays. See also cassandra_task_delay.

Example Playbook

This playbook provides a simple setup for Cassandra with a basic configuration:

---
- name: Example Playbook for the locp.cassandra Role

  hosts: cassandra

  remote_user: root

  vars:
    cassandra_configuration:
      authenticator: PasswordAuthenticator
      cluster_name: MyCassandraCluster
      commitlog_directory: /data/cassandra/commitlog
      commitlog_sync: periodic
      commitlog_sync_period_in_ms: 10000
      data_file_directories:
        - /data/cassandra/data
      endpoint_snitch: GossipingPropertyFileSnitch
      hints_directory: "/data/cassandra/hints"
      listen_address: "{{ ansible_default_ipv4.address }}"
      num_tokens: 4
      partitioner: org.apache.cassandra.dht.Murmur3Partitioner
      saved_caches_directory: /data/cassandra/saved_caches
      seed_provider:
        - class_name: "org.apache.cassandra.locator.SimpleSeedProvider"
          parameters:
            - seeds: "{{ hostvars[groups['cassandra'][0]]['ansible_default_ipv4'].address }}"
      start_native_transport: true
    cassandra_configure_apache_repo: true
    cassandra_directories:
      root:
        group: root
        mode: "0755"
        owner: root
        paths:
          - /data
      data:
        paths:
          - /data/cassandra
          - /data/cassandra/commitlog
          - /data/cassandra/data
          - /data/cassandra/hints
          - /data/cassandra/saved_caches
    cassandra_regex_replacements:
      - path: cassandra-env.sh
        line: 'MAX_HEAP_SIZE="{{ cassandra_max_heapsize_mb }}M"'
        regexp: '^#MAX_HEAP_SIZE="4G"'
      - path: cassandra-env.sh
        line: 'HEAP_NEWSIZE="{{ cassandra_heap_new_size_mb }}M"'
        regexp: '^#HEAP_NEWSIZE="800M"'
      - path: cassandra-rackdc.properties
        line: 'dc=DC1'
        regexp: '^dc='
      - path: cassandra-rackdc.properties
        line: 'rack=RACK1'
        regexp: '^rack='
    cassandra_repo_apache_release: 40x

  roles:
    - role: locp.cassandra

For testing playbooks, see molecule/default/converge.yml and molecule/combine_cluster/converge.yml.

License

GPLv3

Author Information

Created by the League of Crafty Programmers Ltd.

For issues and contributions, please visit https://github.com/locp/ansible-role-cassandra/issues

Informazioni sul progetto

Ansible role to install Apache Cassandra.

Installa
ansible-galaxy install locp.cassandra
Licenza
lgpl-3.0
Download
22.9k