{"id":15056864,"url":"https://github.com/locp/ansible-role-cassandra","last_synced_at":"2025-10-04T16:31:53.676Z","repository":{"id":34590413,"uuid":"131017860","full_name":"locp/ansible-role-cassandra","owner":"locp","description":"Ansible role to install and configure Apache Cassandra","archived":true,"fork":false,"pushed_at":"2023-02-08T04:46:09.000Z","size":400,"stargazers_count":27,"open_issues_count":3,"forks_count":19,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2024-09-30T04:05:25.743Z","etag":null,"topics":["ansible","apache-cassandra","cassandra","nosql"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/locp/cassandra","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/locp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-25T14:19:44.000Z","updated_at":"2024-02-22T07:33:54.000Z","dependencies_parsed_at":"2023-01-15T07:57:47.750Z","dependency_job_id":null,"html_url":"https://github.com/locp/ansible-role-cassandra","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locp%2Fansible-role-cassandra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locp%2Fansible-role-cassandra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locp%2Fansible-role-cassandra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locp%2Fansible-role-cassandra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/locp","download_url":"https://codeload.github.com/locp/ansible-role-cassandra/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235285435,"owners_count":18965324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","apache-cassandra","cassandra","nosql"],"created_at":"2024-09-24T21:57:15.612Z","updated_at":"2025-10-04T16:31:48.312Z","avatar_url":"https://github.com/locp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible-role-cassandra\n\n[![Gitter](https://badges.gitter.im/ansible-role-cassandra/community.svg)](https://gitter.im/ansible-role-cassandra/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n[![CI](https://github.com/locp/ansible-role-cassandra/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/locp/ansible-role-cassandra/actions/workflows/ci.yml)\n\nAnsible role to install and configure\n[Apache Cassandra](http://cassandra.apache.org/).\n\n## Requirements\n\n### OS Family Identification\nThe Ansible playbook must gather enough facts to have the `ansible_os_family`\nvariable to be set.\n\n### Python Modules\nOn Debian systems that set `cassandra_configure_apache_repo` to **True** please\nnote that the\n[`apt_repository`](http://docs.ansible.com/ansible/latest/modules/apt_repository_module.html)\nmodule is used.  Therefore the below requirements are needed on the host that\nexecutes this module.\n\n* python-apt (python 2)\n* python3-apt (python 3)\n\n## Role Variables\n\n* `cassandra_15770_workaround`: (default: *False*)\n  [CASSANDRA-15770](https://issues.apache.org/jira/browse/CASSANDRA-15770)\n  affected Debian 10 and Ubuntu 20.04 it was subsequently fixed in versions\n  3.0.21, 3.11.7, 4.0.  As we are running our tests against 3.11.6 at the\n  moment, this applies the fix to `/etc/init.d/cassandra` if set to True.\n\n* `cassandra_2356_workaround`: (default: *False*)\n  [CASSANDRA-2356](https://issues.apache.org/jira/browse/CASSANDRA-2356)\n  affected deb packages for Cassandra versions pre-4.0.\n\n* `cassandra_cms_heap_new_size_mb`:\n  A custom fact that returns a value (MB) that might be suitable to set the\n  HEAP_NEWSIZE when using the Concurrent Mark Sweep (CMS) Collector.  See\n  [Tuning Java resources](https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html)\n  for more details.  Requires the `cassandra_memtotal_mb` and\n  `cassandra_processor_vcpus` facts to be set.\n\n* `cassandra_cms_max_heapsize_mb`:\n  A custom fact that returns a value (MB) that might be suitable to set the\n  MAX_HEAP_SIZE when using the Concurrent Mark Sweep (CMS) Collector.  See\n  [Tuning Java resources](https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html)\n  for more details.  Requires the `cassandra_memtotal_mb` fact to be set.\n\n* `cassandra_configuration` (default: *none*):\n  The configuration for Cassandra.  See the example play book below.\n\n* `cassandra_configuration_directory` (default:\n  `/etc/cassandra/default.conf` on RedHat and\n  `/etc/cassandra` in Debian):\n  The directory of the Cassandra configuration.\n\n* `cassandra_configuration_file` (default:\n  `/etc/cassandra/default.conf/cassandra.yaml` on RedHat and\n  `/etc/cassandra/cassandra.yaml` on Debian):\n  The location of the Cassandra configuration file.\n\n* `cassandra_configuration_templ` (default: `cassandra.yaml.j2`):\n  Name of the template file for Cassandra configuration.\n\n* `cassandra_configure_apache_repo` (default: **False**):\n  Whether to configure the Apache Cassandra repository.\n\n  **SEE ALSO:** `cassandra_repo_apache_release`.\n\n* `cassandra_dc`:\n  If defined will set the Datacenter in `cassandra-rackdc.properties`.\n\n  This option is deprecated and will be removed in a future release.  Please\n  use `cassandra_regex_replacements` instead.\n\n* `cassandra_directories`:\n  If defined, this will create directories after the package has been\n  installed (therefore when the cassandra user is available) but before\n  Cassandra is configured.  See the example playbook for more details.\n\n  Please note that when used with the `cassandra_join_cluster` option the\n  paths specified here will be deleted (with all their contents) and\n  recreated so that the node can join a cluster correctly.\n\n* `cassandra_heap_new_size_mb`:\n  A custom fact that returns a value (MB) that might be suitable to set the\n  HEAP_NEWSIZE.  See\n  [Tuning Java resources](https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html)\n  for more details.  Requires the `cassandra_memtotal_mb` and\n  `cassandra_processor_vcpus` facts to be set.\n\n* `cassandra_install_packages` (default: **True**):\n  A boolean value indicating if this Ansible role should attempt to install\n  packages or not.  If set to **False** it allows a user to use this role to\n  configure Cassandra but does not attempt to install it (e.g. they have\n  installed from source code).\n\n* `cassandra_join_cluster` (default: **False**):\n  This is an experimental feature, use with extreme caution!  If set to true\n  and the `cassandra_node_count` is found to be 1 on a node, the following\n  actions will take place on that node before the node is configured:\n  - Cassandra will be stopped\n  - The Cassandra data directory/directories will be cleared of all data.\n\n  When that has been done, the node will be reconfigured and join a cluster\n  (which should be larger in size than one node).\n\n* `cassandra_max_heapsize_mb`:\n  A custom fact that returns a value (MB) that might be suitable to set the\n  MAX_HEAP_SIZE.  See\n  [Tuning Java resources](https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.html)\n  for more details.  Requires the `cassandra_memtotal_mb` fact to be set.\n\n* `cassandra_memtotal_mb` (default: `ansible_memtotal_mb` if set):\n  Is used to calculate\n  `cassandra_cms_max_heapsize_mb`, `cassandra_max_heapsize_mb`,\n  `cassandra_cms_heap_new_size_mb` and `cassandra_heap_new_size_mb`.\n\n* `cassandra_path`\n  This variable was introduced in version 1.4.0 but was\n  missed from being documented.  As\n  [pointed out](https://github.com/locp/ansible-role-cassandra/issues/116) if the variable is defined when the\n  variable is set and the directory is deleted, it is not\n  recreated.  The variable has now been deprecated in\n  favour of `cassandra_directories`.\n\n* `cassandra_node_count`:\n  A read-only variable that attempts to contain the number of nodes in the\n  cluster.  Will only be set if `cassandra_join_cluster` is set to `True`.\n\n* `cassandra_package` (default: `cassandra`):\n  The name of the package to be installed to provide Cassandra.\n\n* `cassandra_processor_vcpus` (default: `ansible_processor_vcpus` if set):\n  Is used to calculate `cassandra_cms_heap_new_size_mb` and\n  `cassandra_heap_new_size_mb`.\n\n* `cassandra_rack`:\n  If defined will set the rack in `cassandra-rackdc.properties`.\n\n  This option is deprecated and will be removed in a future release.  Please\n  use `cassandra_regex_replacements` instead.\n\n* `cassandra_regex_replacements` (default: []):\n  A list of hashes describing a `path` which is relative to\n  `cassandra_configuration_directory`, `regexp` which is a regular\n  expression to find in a file and `line` is the replacement within the\n  file.  See the example playbook for more details.\n\n* `cassandra_repo_apache_release` (default: *None*):\n  The name of the release series (can be one of 40x, 311x, or 30x).  This\n  must be set if `cassandra_configure_apache_repo` is set to True.\n\n* `cassandra_service_enabled` (default: **yes**):\n  Should the cassandra service be enabled (can be yes or no).\n\n* `cassandra_service_restart` (default: **True**):\n  If set to true, changes to the Cassandra configuration file or the data\n  directories will ensure that Cassandra service is refreshed after the\n  changes.  Setting this flag to false will disable this behaviour, therefore\n  allowing the changes to be made but allow the user to control when the service\n  is restarted.\n\n* `cassandra_systemd_enabled` (default: **False**):\n  Should the Cassandra service by enabled via\n  [systemd](https://freedesktop.org/wiki/Software/systemd/)\n  if set to **True** then a unit file will be placed in\n  `cassandra_systemd_path` created from template\n  `cassandra_systemd_template`.\n\n* `cassandra_systemd_path` (default: `/usr/lib/systemd/system/cassandra.service`):\n  The path to a unit file for Cassandra.  This variable is ignored if\n  `cassandra_systemd_enabled` is **False**.\n\n* `cassandra_systemd_template` (default:\n  `\"systemd/system/cassandra.service.j2\"`:\n  The path for a template from which to create unit file for Cassandra.  This\n  variable is ignored if `cassandra_systemd_enabled` is **False**.\n\n* `cassandra_task_delay` (default: 10):\n  Ansible tasks that rely on network connectivity (i.e. `apt`, `apt_key`,\n  `apt_repository`, `package` and `yum`) may be affected by high latency\n  so those tasks are configured to retry.  This parameter is how long to\n  wait between attempts.  See also `cassandra_task_retries`.\n\n* `cassandra_task_retries` (default: 5):\n  Ansible tasks that rely on network connectivity (i.e. `apt`, `apt_key`,\n  `apt_repository`, `package` and `yum`) may be affected by high latency\n  so those tasks are configured to retry.  This parameter is how many\n  attempts should be made.  See also `cassandra_task_delay`.\n\n## Example Playbook\n\nThis playbook should be enough to configure Cassandra with a *very* basic\n[configuration](https://cassandra.apache.org/doc/latest/getting_started/configuring.html):\n\n```YAML\n---\n- name: Example Playbook for the locp.cassandra Role\n\n  hosts: cassandra\n\n  remote_user: root\n\n  vars:\n    cassandra_configuration:\n      authenticator: PasswordAuthenticator\n      cluster_name: MyCassandraCluster\n      commitlog_directory: /data/cassandra/commitlog\n      commitlog_sync: periodic\n      commitlog_sync_period_in_ms: 10000\n      data_file_directories:\n        - /data/cassandra/data\n      endpoint_snitch: GossipingPropertyFileSnitch\n      hints_directory: \"/data/cassandra/hints\"\n      listen_address: \"{{ ansible_default_ipv4.address }}\"\n      # For a sensible value to set num_tokens to, please see\n      # https://cassandra.apache.org/doc/latest/getting_started/production.html#tokens\n      num_tokens: 4\n      partitioner: org.apache.cassandra.dht.Murmur3Partitioner\n      saved_caches_directory: /data/cassandra/saved_caches\n      seed_provider:\n        - class_name: \"org.apache.cassandra.locator.SimpleSeedProvider\"\n          parameters:\n            # This sets the seed to the first node in the Ansible group called\n            # cassandra.\n            - seeds: \"{{ hostvars[groups['cassandra'][0]]['ansible_default_ipv4'].address }}\"\n      start_native_transport: true\n    cassandra_configure_apache_repo: true\n    # Create an alternative directories structure for the Cassandra data.\n    # In this example, the will be a directory called /data owned by root\n    # with rwxr-xr-x permissions.  It will have a series of sub-directories\n    # all of which will be defaulted to being owned by the cassandra user\n    # with rwx------ permissions.\n    cassandra_directories:\n      root:\n        group: root\n        mode: \"0755\"\n        owner: root\n        paths:\n          - /data\n      data:\n        paths:\n          - /data/cassandra\n          - /data/cassandra/commitlog\n          - /data/cassandra/data\n          - /data/cassandra/hints\n          - /data/cassandra/saved_caches\n    cassandra_regex_replacements:\n      - path: cassandra-env.sh\n        line: 'MAX_HEAP_SIZE=\"{{ cassandra_max_heapsize_mb }}M\"'\n        regexp: '^#MAX_HEAP_SIZE=\"4G\"'\n      - path: cassandra-env.sh\n        line: 'HEAP_NEWSIZE=\"{{ cassandra_heap_new_size_mb }}M\"'\n        regexp: '^#HEAP_NEWSIZE=\"800M\"'\n      - path: cassandra-rackdc.properties\n        line: 'dc=DC1'\n        regexp: '^dc='\n      - path: cassandra-rackdc.properties\n        line: 'rack=RACK1'\n        regexp: '^rack='\n    cassandra_repo_apache_release: 40x\n\n  roles:\n    - role: locp.cassandra\n```\n\nTo see the playbooks that are used for\n[testing](CONTRIBUTING.md#testing) see\n[molecule/default/converge.yml](molecule/default/converge.yml)\nand\n[molecule/combine_cluster/converge.yml](molecule/combine_cluster/converge.yml).\n\n## License\n\n[GPLv3](https://github.com/locp/ansible-role-cassandra/blob/master/LICENSE)\n\n## Author Information\n\nDeveloped by the\n[League of Crafty Programmers](http://www.locp.co.uk) Ltd.\n\nTo raise issues or make contributions, please go to\nhttps://github.com/locp/ansible-role-cassandra/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocp%2Fansible-role-cassandra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocp%2Fansible-role-cassandra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocp%2Fansible-role-cassandra/lists"}