├── .github ├── CODEOWNERS ├── settings.yml └── workflows │ ├── ansible-test.yml │ ├── publish_collection.yml │ ├── rebase.yml │ └── test-roles.yml ├── .gitignore ├── CHANGELOG.rst ├── LICENSE ├── README.md ├── changelogs └── changelog.yaml ├── galaxy.yml ├── meta └── runtime.yml ├── plugins ├── doc_fragments │ └── nodetool_module_options.py ├── module_utils │ ├── __init__.py │ ├── cassandra_common_options.py │ └── nodetool_cmd_objects.py └── modules │ ├── cassandra_assassinate.py │ ├── cassandra_autocompaction.py │ ├── cassandra_backup.py │ ├── cassandra_batchlogreplaythrottle.py │ ├── cassandra_binary.py │ ├── cassandra_cleanup.py │ ├── cassandra_compact.py │ ├── cassandra_compactionthreshold.py │ ├── cassandra_compactionthroughput.py │ ├── cassandra_concurrency.py │ ├── cassandra_cqlsh.py │ ├── cassandra_decommission.py │ ├── cassandra_drain.py │ ├── cassandra_flush.py │ ├── cassandra_fullquerylog.py │ ├── cassandra_garbagecollect.py │ ├── cassandra_gossip.py │ ├── cassandra_handoff.py │ ├── cassandra_interdcstreamthroughput.py │ ├── cassandra_invalidatecache.py │ ├── cassandra_keyspace.py │ ├── cassandra_maxhintwindow.py │ ├── cassandra_reload.py │ ├── cassandra_removenode.py │ ├── cassandra_role.py │ ├── cassandra_schema.py │ ├── cassandra_status.py │ ├── cassandra_stopdaemon.py │ ├── cassandra_streamthroughput.py │ ├── cassandra_table.py │ ├── cassandra_thrift.py │ ├── cassandra_timeout.py │ ├── cassandra_traceprobability.py │ ├── cassandra_truncatehints.py │ ├── cassandra_upgradesstables.py │ └── cassandra_verify.py ├── requirements-2.7.txt ├── requirements-3.5.txt ├── requirements-3.6.txt ├── requirements-3.8.txt ├── roles ├── cassandra_firewall │ ├── .yamllint │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── meta │ │ └── main.yml │ ├── molecule │ │ ├── .travisignore │ │ ├── default │ │ │ ├── Dockerfile.j2 │ │ │ ├── files │ │ │ │ └── firewalld_fix.sh │ │ │ ├── molecule.yml │ │ │ ├── playbook.yml │ │ │ ├── prepare.yml │ │ │ └── tests │ │ │ │ └── test_default.py │ │ └── virtualbox │ │ │ ├── files │ │ │ └── firewalld_fix.sh │ │ │ ├── molecule.yml │ │ │ ├── playbook.yml │ │ │ ├── prepare.yml │ │ │ └── tests │ │ │ └── test_default.py │ ├── tasks │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ └── RedHat.yml ├── cassandra_install │ ├── .yamllint │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── meta │ │ └── main.yml │ ├── molecule │ │ └── default │ │ │ ├── Dockerfile.j2 │ │ │ ├── molecule.yml │ │ │ ├── playbook.yml │ │ │ └── tests │ │ │ └── test_default.py │ └── tasks │ │ ├── jdk1.8_Debian_Buster.yml │ │ └── main.yml ├── cassandra_linux │ ├── .yamllint │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── files │ │ └── disable-thp.service │ ├── handlers │ │ └── main.yml │ ├── meta │ │ └── main.yml │ ├── molecule │ │ └── default │ │ │ ├── Dockerfile.j2 │ │ │ ├── molecule.yml │ │ │ ├── playbook.yml │ │ │ ├── prepare.yml │ │ │ └── tests │ │ │ └── test_default.py │ ├── tasks │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ └── RedHat.yml └── cassandra_repository │ ├── .yamllint │ ├── README.md │ ├── defaults │ └── main.yml │ ├── meta │ └── main.yml │ ├── molecule │ └── default │ │ ├── Dockerfile.j2 │ │ ├── molecule.yml │ │ ├── playbook.yml │ │ └── tests │ │ └── test_default.py │ └── tasks │ └── main.yml ├── stale.yml └── tests ├── coverage.sh ├── integration └── targets │ ├── cassandra_assassinate │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_autocompaction │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_backup │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_batchlogreplaythrottle │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_binary │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_cleanup │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_compact │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_compactionthreshold │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_compactionthroughput │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_concurrency │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_cqlsh │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_decommission │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_drain │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_flush │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_fullquerylog │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_garbagecollect │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_gossip │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_handoff │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_interdcstreamthroughput │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_invalidatecache │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_keyspace │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── 284.yml │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ ├── RedHat.yml │ │ └── main.yml │ ├── cassandra_maxhintwindow │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_reload │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_removenode │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_role │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── 204.yml │ │ ├── 284.yml │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ ├── RedHat.yml │ │ └── main.yml │ ├── cassandra_schema │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_ssl │ ├── files │ │ ├── cassandra.crt │ │ ├── cassandra.pem │ │ ├── client_cert.pem │ │ ├── client_key.pem │ │ ├── keystore.jks │ │ ├── ssl-test.cer.pem │ │ ├── ssl-test.key.pem │ │ ├── ssl-test.p12 │ │ └── truststore.jks │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ ├── RedHat.yml │ │ └── main.yml │ ├── cassandra_status │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_stopdaemon │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_streamthroughput │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_table │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── 284.yml │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ ├── RedHat.yml │ │ └── main.yml │ ├── cassandra_thrift │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_timeout │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── main.yml │ │ └── timeout_test.yml │ └── vars │ │ └── main.yml │ ├── cassandra_traceprobability │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_truncatehints │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_upgradesstables │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml │ ├── cassandra_verify │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── 4_1_verify_disabled.yml │ │ ├── main.yml │ │ └── old_verify.yml │ └── vars │ │ └── main.yml │ ├── setup_cassandra │ ├── defaults │ │ └── main.yml │ ├── files │ │ ├── KEYS │ │ ├── cassandra │ │ └── cassandra_debian │ ├── handlers │ │ ├── cleanup_debian_env.yml │ │ ├── cleanup_redhat7_env.yml │ │ └── main.yml │ ├── tasks │ │ ├── cassandra_auth.yml │ │ ├── cassandra_deauth.yml │ │ └── main.yml │ └── vars │ │ ├── Debian.yml │ │ └── RedHat.yml │ └── setup_cassandra_cluster_manager │ ├── defaults │ └── main.yml │ └── tasks │ └── main.yml └── sanity ├── ignore-2.15.txt ├── ignore-2.16.txt ├── ignore-2.17.txt ├── ignore-2.18.txt └── ignore-2.19.txt /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | .github 2 | 3 | # Repo maintainers, and goverance team (like Anisble's @ansible-commit-external) 4 | * @rrey @seuf @gundalow-collections/community-goverance-team 5 | 6 | # or possibly, we may want to define teams at the org level. 7 | # * @gundalow-collections/grafana-maintainers 8 | 9 | # Example of maintainer of just a single plugin 10 | #grafana/plugins/modules/grafana_plugin.py @someone-else 11 | 12 | 13 | .github/ @rhysmeister 14 | -------------------------------------------------------------------------------- /.github/settings.yml: -------------------------------------------------------------------------------- 1 | ### 2 | # https://probot.github.io/apps/settings/ 3 | # 4 | 5 | # DO NOT MODIFY 6 | # this is a copy of https://github.com/gundalow-collection/.github/blob/master/.github/settings.yml 7 | # Work around till https://github.com/probot/settings/pull/179 is merged 8 | 9 | 10 | 11 | repository: 12 | # See https://developer.github.com/v3/repos/#edit for all available settings. 13 | has_issues: true 14 | has_wiki: false 15 | has_pages: false 16 | default_branch: devel 17 | allow_squash_merge: true 18 | allow_merge_commit: false 19 | allow_rebase_merge: true 20 | 21 | # Labels: define labels for Issues and Pull Requests 22 | labels: 23 | - name: bug 24 | color: fbca04 25 | description: This issue/PR relates to a bug. 26 | - name: feature 27 | description: This issue/PR relates to a feature request. 28 | color: 006b75 29 | - name: migrated_from_ansible_ansible 30 | color: 5319e7 31 | description: This issue/PR was moved from gh/ansible/ansible 32 | 33 | branches: 34 | - name: devel 35 | # https://developer.github.com/v3/repos/branches/#update-branch-protection 36 | # Branch Protection settings. Set to null to disable 37 | protection: 38 | # Required. Require at least one approving review on a pull request, before merging. Set to null to disable. 39 | required_pull_request_reviews: 40 | # The number of approvals required. (1-6) 41 | required_approving_review_count: 1 42 | # Dismiss approved reviews automatically when a new commit is pushed. 43 | dismiss_stale_reviews: true 44 | # Blocks merge until code owners have reviewed. 45 | require_code_owner_reviews: true 46 | # Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories. 47 | dismissal_restrictions: 48 | users: [] 49 | teams: [] 50 | # Required. Require status checks to pass before merging. Set to null to disable 51 | required_status_checks: 52 | # Required. Require branches to be up to date before merging. 53 | strict: true 54 | # Required. The list of status checks to require in order to merge into this branch 55 | contexts: [] 56 | # Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable. 57 | enforce_admins: true 58 | # Required. Restrict who can push to this branch. Team and user restrictions are only available for organization-owned repositories. Set to null to disable. 59 | #restrictions: 60 | # users: [] 61 | # teams: [] 62 | - name: master 63 | # https://developer.github.com/v3/repos/branches/#update-branch-protection 64 | # Branch Protection settings. Set to null to disable 65 | protection: 66 | # Required. Require at least one approving review on a pull request, before merging. Set to null to disable. 67 | required_pull_request_reviews: 68 | # The number of approvals required. (1-6) 69 | required_approving_review_count: 1 70 | # Dismiss approved reviews automatically when a new commit is pushed. 71 | dismiss_stale_reviews: true 72 | # Blocks merge until code owners have reviewed. 73 | require_code_owner_reviews: true 74 | # Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories. 75 | dismissal_restrictions: 76 | users: [] 77 | teams: [] 78 | # Required. Require status checks to pass before merging. Set to null to disable 79 | required_status_checks: 80 | # Required. Require branches to be up to date before merging. 81 | strict: true 82 | # Required. The list of status checks to require in order to merge into this branch 83 | contexts: [] 84 | # Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable. 85 | enforce_admins: true 86 | # Required. Restrict who can push to this branch. Team and user restrictions are only available for organization-owned repositories. Set to null to disable. 87 | #restrictions: 88 | # users: [] 89 | # teams: [] 90 | -------------------------------------------------------------------------------- /.github/workflows/publish_collection.yml: -------------------------------------------------------------------------------- 1 | name: Build & Publish Collection 2 | on: 3 | push: 4 | branches: 5 | - master 6 | 7 | jobs: 8 | build_publish: 9 | 10 | runs-on: ubuntu-20.04 11 | defaults: 12 | run: 13 | working-directory: ansible_collections/community/cassandra 14 | steps: 15 | 16 | - name: Check out code 17 | uses: actions/checkout@v4 18 | with: 19 | path: ansible_collections/community/cassandra 20 | 21 | - name: Set up Python 3.12 22 | uses: actions/setup-python@v5 23 | with: 24 | python-version: "3.12" 25 | 26 | - name: Install ansible-base (devel) 27 | uses: nick-invision/retry@v3 28 | with: 29 | timeout_minutes: 3 30 | max_attempts: 3 31 | command: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check 32 | 33 | - name: Build the collection 34 | run: ansible-galaxy collection build 35 | 36 | - name: Rename the build artifact 37 | run: mv community-cassandra-*.tar.gz community-cassandra-latest.tar.gz 38 | 39 | - name: Upload community-cassandra-latest.tar.gz as an artifact 40 | uses: actions/upload-artifact@v4 41 | with: 42 | name: community-cassandra-latest 43 | path: ansible_collections/community/cassandra/community-cassandra-latest.tar.gz 44 | 45 | # Moving the tag leaves an orphan artifact. Just changing the artifact doesn't move the tag. 46 | - name: Delete latest tag and release 47 | uses: dev-drprasad/delete-tag-and-release@v1.0.1 48 | with: 49 | delete_release: true 50 | tag_name: latest 51 | env: 52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 53 | 54 | - name: Upload files to release 55 | uses: svenstaro/upload-release-action@v2 56 | with: 57 | repo_token: ${{ secrets.GITHUB_TOKEN }} 58 | file: ansible_collections/community/cassandra/community-cassandra-latest.tar.gz 59 | asset_name: community-cassandra-latest.tar.gz 60 | body: "Development release" 61 | tag: latest 62 | overwrite: true 63 | -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/automatic-rebase 2 | # GitHub Actions don't automatically rebase before running, so add support for people to type `/rebase` 3 | on: 4 | issue_comment: 5 | types: [created] 6 | name: Automatic Rebase 7 | jobs: 8 | rebase: 9 | name: Rebase 10 | if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') 11 | runs-on: ubuntu-20.04 12 | steps: 13 | - uses: actions/checkout@master 14 | - name: Automatic Rebase 15 | uses: cirrus-actions/rebase@master 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | # https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250 19 | always_job: 20 | name: Aways run job 21 | runs-on: ubuntu-20.04 22 | steps: 23 | - name: Always run 24 | run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped." 25 | -------------------------------------------------------------------------------- /.github/workflows/test-roles.yml: -------------------------------------------------------------------------------- 1 | name: CI_roles 2 | on: 3 | pull_request: 4 | schedule: 5 | - cron: "0 6 * * *" 6 | 7 | jobs: 8 | 9 | roles_matrix: 10 | runs-on: ubuntu-20.04 11 | defaults: 12 | run: 13 | working-directory: ansible_collections/community/cassandra 14 | outputs: 15 | matrix: ${{ steps.json-list.outputs.roles-to-test }} 16 | 17 | steps: 18 | 19 | - name: Check out code 20 | uses: actions/checkout@v4 21 | with: 22 | path: ansible_collections/community/cassandra 23 | 24 | - name: Generate module list 25 | run: | 26 | find roles -type d -maxdepth 1 -mindepth 1 -not -name cassandra_medusa | cut -d '/' -f2 | awk NF | jq -sRc 'split("\n") | map(select(length > 0))' > int_test_roles.json 27 | 28 | - name: Set output variable 29 | id: json-list 30 | run: | 31 | output=$(cat int_test_roles.json) 32 | echo "roles-to-test=$output" >> $GITHUB_OUTPUT 33 | echo "$output" 34 | 35 | roles: 36 | runs-on: ubuntu-20.04 37 | needs: roles_matrix 38 | defaults: 39 | run: 40 | working-directory: ansible_collections/community/cassandra 41 | 42 | strategy: 43 | matrix: 44 | python_version: 45 | - "3.10" 46 | cassandra_role: ${{ fromJson(needs.roles_matrix.outputs.matrix) }} 47 | 48 | steps: 49 | - name: Check out code 50 | uses: actions/checkout@v4 51 | with: 52 | path: ansible_collections/community/cassandra 53 | 54 | - name: Set up Python ${{ matrix.test_scenario.python_version }} 55 | uses: actions/setup-python@v5 56 | with: 57 | python-version: ${{ matrix.test_scenario.python_version }} 58 | 59 | - name: Uninstall existing ansible 60 | run: sudo apt remove ansible 61 | 62 | - name: Ensure wheel is installed 63 | uses: nick-invision/retry@v3 64 | with: 65 | timeout_minutes: 3 66 | max_attempts: 3 67 | command: pip install wheel 68 | 69 | - name: Install requirements 70 | uses: nick-invision/retry@v3 71 | with: 72 | timeout_minutes: 3 73 | max_attempts: 3 74 | command: | 75 | export pyv=$(python -c 'from platform import python_version; print(python_version()[:3])') 76 | cd ansible_collections/community/cassandra 77 | pip install --requirement requirements-${pyv}.txt 78 | 79 | - name: Install ansible.posix 80 | uses: nick-invision/retry@v3 81 | with: 82 | timeout_minutes: 3 83 | max_attempts: 3 84 | command: ansible-galaxy collection install ansible.posix -p ansible_collections/ 85 | 86 | - name: Add molecule location to path 87 | run: echo "${HOME}/.local/bin" >> $GITHUB_PATH 88 | 89 | - name: Run molecule test for ${{ matrix.cassandra_role }} 90 | run: molecule test 91 | working-directory: ansible_collections/community/cassandra/roles/${{ matrix.cassandra_role }} 92 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | .DS_Store 3 | venv/ 4 | tests/output/ 5 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | =============================== 2 | community.cassandra Release Notes 3 | =============================== 4 | 5 | .. contents:: Topics 6 | 7 | v1.3.2 8 | ======= 9 | 10 | Release Summary 11 | --------------- 12 | 13 | Version bumped to get the auto-release running. 14 | 15 | Minor Changes 16 | ------------- 17 | 18 | - None 19 | 20 | v1.3.2 21 | ======= 22 | 23 | Release Summary 24 | --------------- 25 | 26 | Maintenance release 27 | 28 | Minor Changes 29 | ------------- 30 | 31 | - 274 - cassandra_keyspace & cassandra_role - Ensure that data_centres parameter and aliases are consistent. 32 | 33 | v1.3.1 34 | ======= 35 | 36 | Release Summary 37 | --------------- 38 | 39 | Maintenance release 40 | 41 | Minor Changes 42 | ------------- 43 | 44 | - 269 - cassandra_role - Allow for update of passwords. 45 | 46 | Bug Fixes 47 | --------- 48 | 49 | - 259 - cassandra_repository - Fix repo url. 50 | - 258 - cassandra_repository - Add static key. 51 | 52 | v1.3.0: 53 | ======= 54 | 55 | Release Summary 56 | --------------- 57 | 58 | Maintenance release 59 | 60 | Minor Changes 61 | ------------- 62 | 63 | - 230 - Adds basic SSL/TLS support to the cassandra_keyspace, cassandra_role and cassandra_table modules. 64 | 65 | v1.2.4: 66 | ======= 67 | 68 | Release Summary 69 | --------------- 70 | 71 | Maintenance release 72 | 73 | Bug Fixes 74 | --------- 75 | 76 | - 244 cassandra_repository - Update APT Repository url. 77 | 78 | v1.2.3: 79 | ======= 80 | 81 | Release Summary 82 | --------------- 83 | 84 | Maintenance release 85 | 86 | Bug Fixes 87 | --------- 88 | 89 | - 239 - cassandra_role - Adds quoting to role name to support special characters in the role name, i.e. my-app-role. 90 | 91 | v1.2.2: 92 | ======= 93 | 94 | Release Summary 95 | --------------- 96 | 97 | Maintenance release 98 | 99 | Bug Fixes 100 | --------- 101 | 102 | - 214 - cassandra_fullquerylog - Fix typo in documentation. 103 | - 213 - cassandra_cqlsh - Missing handler for `--ssl` option for `cassandra_cqlsh` 104 | -------------------------------------------------------------------------------- /changelogs/changelog.yaml: -------------------------------------------------------------------------------- 1 | releases: 2 | 1.0.4: 3 | changes: 4 | release_summary: "Maintenance release" 5 | bug_fixes: 6 | - cassandra_cqlsh - Double quote cql shell command when it contains single quotes. 7 | - All modules - Ensure login parameters are available across all modules. 8 | release_date: '2021-02-27' 9 | 1.0.5: 10 | changes: 11 | release_summary: "Maintenance release" 12 | bugfixes: 13 | - Remove cassandra_dba role. 14 | - Add missing metadata to existing roles. 15 | release_date: '2021-04-21' 16 | 1.0.6: 17 | changes: 18 | release_summary: "Maintenance release" 19 | bugfixes: 20 | - Improve regex in cassandra_keyspace module - PR160. 21 | - Fix import error in cassandra_cqlsh after 311x upgrade - PR158. 22 | minor_changes: 23 | - Various minor module documentation improvements PR161. 24 | - Add additional_args parameter to cassandra_cqlsh module PR149. 25 | 1.1.0: 26 | changes: 27 | release_summary: Adds new module cassandra_reload and provides a few minor fixes. 28 | minor_changes: 29 | - 183 - Adds new module cassandra_reload. 30 | - 182 - Add retries to network related tasks in all roles. 31 | - A bunch of other PRs addressed issues in the integration test code related to Cassandra 4.0. 32 | 1.2.0: 33 | changes: 34 | release_summary: Adds many new modules and a minor bug fix. 35 | bugfixes: 36 | - 204 - Fix cassandra_role keyspace idempotency bug. 37 | modules: 38 | - name: cassandra_garbagecollect 39 | description: #198 40 | - name: cassandra_maxhintwindow 41 | description: #197 42 | - name: cassandra_batchlogreplaythrottle 43 | description: #196 44 | - name: cassandra_invalidatecache 45 | description: #195 46 | - name: cassandra_removenode 47 | description: #193 48 | - name: cassandra_decommission 49 | description: #192 50 | - name: cassandra_assassinate 51 | description: #191 52 | - name: cassandra_concurrency 53 | description: #189 54 | - name: cassandra_fullquerylog 55 | description: #188 56 | - name: cassandra_truncatehints 57 | description: #187 58 | - name: cassandra_timeout 59 | description: #186 60 | - name: cassandra_compact 61 | description: #185 62 | 1.2.2: 63 | changes: 64 | release_summary: Maintenance release 65 | bugfixes: 66 | - 214 - cassandra_fullquerylog - Fix typo in documentation. 67 | - 213 - cassandra_cqlsh - Missing handler for `--ssl` option for `cassandra_cqlsh` 68 | 1.2.3: 69 | changes: 70 | release_summary: Maintenance release 71 | bugfixes: 72 | - 239 - cassandra_role - Adds quoting to role name to support special characters in the role name, i.e. my-app-role. 73 | 1.2.4: 74 | changes: 75 | release_summary: Maintenance release 76 | bugfixes: 77 | - 244 cassandra_repository - Update APT Repository url. 78 | 1.3.0: 79 | changes: 80 | release_summary: Maintenance release 81 | minor_changes: 82 | - 230 - Adds basic SSL/TLS support to the cassandra_keyspace, cassandra_role and cassandra_table modules. 83 | 1.3.1: 84 | changes: 85 | release_summary: Maintenance release 86 | minor_changes: 87 | - 269 - cassandra_role - Allow for update of passwords. 88 | bugfixes: 89 | - 259 - cassandra_repository - Fix repo url. 90 | - 258 - cassandra_repository - Add static key. 91 | 1.3.2: 92 | changes: 93 | release_summary: Maintenance release 94 | minor_changes: 95 | - 274 - cassandra_keyspace & cassandra_role - Ensure that data_centres parameter and aliases are consistent. 96 | 1.3.3: 97 | changes: 98 | release_summary: Maintenance release. Version bumped to get the auto-release running. 99 | minor_changes: 100 | - None 101 | 1.4.0: 102 | changes: 103 | release_summary: Maintenance release. 104 | minor_changes: 105 | - 287 - Adds the consistency_level parameter to the cassandra_role, cassandra_keyspace and cassandra_table modules. -------------------------------------------------------------------------------- /galaxy.yml: -------------------------------------------------------------------------------- 1 | namespace: community 2 | name: cassandra 3 | version: 1.4.0 4 | readme: README.md 5 | authors: Rhys Campbell 6 | description: null 7 | license: null 8 | license_file: LICENSE 9 | tags: 10 | - cassandra 11 | - nosql 12 | - database 13 | - datastore 14 | dependencies: 15 | community.general: '>=0.1.1' 16 | repository: https://github.com/ansible-collections/community.cassandra 17 | documentation: https://ansible-collections.github.io/community.cassandra/ 18 | homepage: https://github.com/ansible-collections/community.cassandra 19 | issues: https://github.com/ansible-collections/community.cassandra/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc 20 | -------------------------------------------------------------------------------- /meta/runtime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | requires_ansible: '>=2.9.20' -------------------------------------------------------------------------------- /plugins/doc_fragments/nodetool_module_options.py: -------------------------------------------------------------------------------- 1 | from __future__ import (absolute_import, division, print_function) 2 | __metaclass__ = type 3 | 4 | 5 | class ModuleDocFragment(object): 6 | # Standard documentation 7 | DOCUMENTATION = r''' 8 | options: 9 | host: 10 | description: 11 | - The hostname. 12 | type: str 13 | default: 127.0.0.1 14 | aliases: 15 | - "login_host" 16 | port: 17 | description: 18 | - The Cassandra TCP port. 19 | type: int 20 | default: 7199 21 | aliases: 22 | - "login_port" 23 | password: 24 | description: 25 | - The password to authenticate with. 26 | type: str 27 | aliases: 28 | - "login_password" 29 | password_file: 30 | description: 31 | - Path to a file containing the password. 32 | type: str 33 | aliases: 34 | - "login_password_file" 35 | username: 36 | description: 37 | - The username to authenticate with. 38 | type: str 39 | aliases: 40 | - "login_user" 41 | nodetool_path: 42 | description: 43 | - The path to nodetool. 44 | type: str 45 | nodetool_flags: 46 | description: 47 | - Flags to pass to nodetool. 48 | type: str 49 | default: -Dcom.sun.jndi.rmiURLParsing=legacy 50 | debug: 51 | description: 52 | - Enable additional debug output. 53 | type: bool 54 | default: False 55 | cassandra_version: 56 | description: 57 | - Version of Cassandra being connected to by nodetool. 58 | - If a value if not provided we use `nodetool version`to auto-discover it. 59 | type: str 60 | ''' 61 | -------------------------------------------------------------------------------- /plugins/module_utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ansible-collections/community.cassandra/4f25557c951f1e181236f289f6d9b9d9ad53218e/plugins/module_utils/__init__.py -------------------------------------------------------------------------------- /plugins/module_utils/cassandra_common_options.py: -------------------------------------------------------------------------------- 1 | from __future__ import (absolute_import, division, print_function) 2 | __metaclass__ = type 3 | 4 | 5 | def cassandra_common_argument_spec(): 6 | """ 7 | Returns a dict containing common options for the Cassandra modules 8 | in this collection 9 | """ 10 | return dict( 11 | debug=dict(type='bool', default=False), 12 | host=dict(type='str', default="127.0.0.1", aliases=['login_host']), 13 | nodetool_path=dict(type='str', default=None), 14 | password=dict(type='str', no_log=True, aliases=['login_password']), 15 | password_file=dict(type='str', no_log=True, aliases=['login_password_file']), 16 | port=dict(type='int', default=7199, aliases=['login_port']), 17 | username=dict(type='str', no_log=True, aliases=['login_user']), 18 | nodetool_flags=dict(type='str', default="-Dcom.sun.jndi.rmiURLParsing=legacy"), 19 | cassandra_version=dict(type='str', default=None), 20 | ) 21 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_assassinate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_assassinate 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Run the assassinate command against a node. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Run the assassinate command against a node. 19 | - Forcefully removes a dead node without re-replicating any data. 20 | - It is a last resort tool if you cannot successfully use nodetool removenode. 21 | 22 | extends_documentation_fragment: 23 | - community.cassandra.nodetool_module_options 24 | 25 | options: 26 | ip_address: 27 | description: 28 | - IP Address of endpoint to assassinate. 29 | type: str 30 | required: yes 31 | debug: 32 | description: 33 | - Add additional debug output. 34 | type: bool 35 | default: false 36 | ''' 37 | 38 | EXAMPLES = ''' 39 | - name: Assassinate a node 40 | community.cassandra.cassandra_assassinate: 41 | ip_address: 127.0.0.1 42 | ''' 43 | 44 | RETURN = ''' 45 | msg: 46 | description: A short description of what happened. 47 | returned: success 48 | type: str 49 | ''' 50 | 51 | from ansible.module_utils.basic import AnsibleModule 52 | __metaclass__ = type 53 | 54 | 55 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandSimple 56 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 57 | 58 | 59 | def main(): 60 | argument_spec = cassandra_common_argument_spec() 61 | argument_spec.update( 62 | ip_address=dict(type='str', required=True), 63 | debug=dict(type='bool', default=False), 64 | ) 65 | module = AnsibleModule( 66 | argument_spec=argument_spec, 67 | supports_check_mode=False, 68 | ) 69 | 70 | ip_address = module.params['ip_address'] 71 | cmd = 'assassinate -- {0}'.format(ip_address) 72 | 73 | n = NodeToolCommandSimple(module, cmd) 74 | 75 | rc = None 76 | out = '' 77 | err = '' 78 | result = {} 79 | 80 | (rc, out, err) = n.run_command() 81 | out = out.strip() 82 | err = err.strip() 83 | if module.params['debug']: 84 | if out: 85 | result['stdout'] = out 86 | if err: 87 | result['stderr'] = err 88 | 89 | if rc == 0: 90 | result['changed'] = True 91 | result['msg'] = "nodetool assassinate executed successfully for endpoint: {0}".format(ip_address) 92 | module.exit_json(**result) 93 | else: 94 | result['msg'] = "nodetool assassinate did not execute successfully rc: {0}".format(rc) 95 | module.fail_json(**result) 96 | 97 | 98 | if __name__ == '__main__': 99 | main() 100 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_autocompaction.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_autocompaction 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Enables or disables autocompaction. 15 | requirements: [ nodetool ] 16 | description: 17 | - Enables or disables autocompaction. 18 | 19 | extends_documentation_fragment: 20 | - community.cassandra.nodetool_module_options 21 | 22 | options: 23 | keyspace: 24 | description: 25 | - The keyspace on which to change autocompact status. 26 | type: str 27 | required: true 28 | table: 29 | description: 30 | - The table on which to change autocompact status. 31 | type: list 32 | elements: str 33 | required: true 34 | state: 35 | description: 36 | - The required status 37 | type: str 38 | choices: 39 | - "enabled" 40 | - "disabled" 41 | required: true 42 | ''' 43 | 44 | EXAMPLES = ''' 45 | - name: Ensure Cassandra Autocompaction is enabled 46 | community.cassandra.cassandra_autocompaction: 47 | keyspace: system 48 | table: local 49 | state: enabled 50 | 51 | - name: Ensure Cassandra Autocompaction is disabled 52 | community.cassandra.cassandra_autocompaction: 53 | keyspace: system 54 | table: local 55 | state: disabled 56 | ''' 57 | 58 | RETURN = ''' 59 | cassandra_autocompaction: 60 | description: The return state of the executed command. 61 | returned: success 62 | type: str 63 | ''' 64 | 65 | from ansible.module_utils.basic import AnsibleModule 66 | __metaclass__ = type 67 | 68 | 69 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeTool2PairCommand 70 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 71 | 72 | 73 | def main(): 74 | argument_spec = cassandra_common_argument_spec() 75 | argument_spec.update( 76 | keyspace=dict(type='str', required=True, no_log=False), 77 | table=dict(type='list', elements='str', required=True), 78 | state=dict(required=True, choices=['enabled', 'disabled']) 79 | ) 80 | module = AnsibleModule( 81 | argument_spec=argument_spec, 82 | supports_check_mode=False, 83 | ) 84 | 85 | keyspace = module.params['keyspace'] 86 | table = ' '.join(module.params['table']) 87 | enable_cmd = 'enableautocompaction {0} {1}'.format(keyspace, table) 88 | disable_cmd = 'disableautocompaction {0} {1}'.format(keyspace, table) 89 | 90 | n = NodeTool2PairCommand(module, enable_cmd, disable_cmd) 91 | 92 | rc = None 93 | out = '' 94 | err = '' 95 | result = {} 96 | result['changed'] = False 97 | 98 | # We don't know if this has changed or not 99 | if module.params['state'] == "enabled": 100 | 101 | (rc, out, err) = n.enable_command() 102 | out = out.strip() 103 | 104 | if module.params['debug']: 105 | if out: 106 | result['stdout'] = out 107 | if err: 108 | result['stderr'] = err 109 | 110 | if rc != 0: 111 | result['msg'] = "enable command failed" 112 | module.fail_json(name=enable_cmd, 113 | **result) 114 | else: 115 | result['changed'] = True 116 | 117 | elif module.params['state'] == "disabled": 118 | 119 | (rc, out, err) = n.disable_command() 120 | out = out.strip() 121 | 122 | if module.params['debug']: 123 | if out: 124 | result['stdout'] = out 125 | if err: 126 | result['stderr'] = err 127 | 128 | if rc != 0: 129 | result['msg'] = "disable command failed" 130 | module.fail_json(name=disable_cmd, 131 | **result) 132 | else: 133 | result['changed'] = True 134 | 135 | module.exit_json(**result) 136 | 137 | 138 | if __name__ == '__main__': 139 | main() 140 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_batchlogreplaythrottle.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_batchlogreplaythrottle 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Sets the batch log replay throttle. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Sets the batch log replay throttle. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | value: 25 | description: 26 | - KB value to set batch log replay throttle to. 27 | type: int 28 | required: True 29 | ''' 30 | 31 | EXAMPLES = ''' 32 | - name: Set batchlogreplaythrottle with module 33 | cassandra_batchlogreplaythrottle: 34 | value: 1024 35 | ''' 36 | 37 | RETURN = ''' 38 | msg: 39 | description: A breif description of what happened 40 | returned: success 41 | type: str 42 | ''' 43 | 44 | from ansible.module_utils.basic import AnsibleModule 45 | __metaclass__ = type 46 | 47 | 48 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 49 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 50 | 51 | 52 | def main(): 53 | argument_spec = cassandra_common_argument_spec() 54 | argument_spec.update( 55 | value=dict(type='int', required=True) 56 | ) 57 | module = AnsibleModule( 58 | argument_spec=argument_spec, 59 | supports_check_mode=True, 60 | ) 61 | 62 | set_cmd = "setbatchlogreplaythrottle {0}".format(module.params['value']) 63 | get_cmd = "getbatchlogreplaythrottle" 64 | value = module.params['value'] 65 | 66 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 67 | 68 | rc = None 69 | out = '' 70 | err = '' 71 | result = {} 72 | 73 | (rc, out, err) = n.get_command() 74 | out = out.strip() 75 | 76 | if module.params['debug']: 77 | if out: 78 | result['stdout'] = out 79 | if err: 80 | result['stderr'] = err 81 | 82 | get_response = "Batchlog replay throttle: {0} KB/s".format(value) 83 | if get_response == out: 84 | 85 | if rc != 0: 86 | result['changed'] = False 87 | module.fail_json(name=get_cmd, 88 | msg="{0} command failed".format(get_cmd), **result) 89 | else: 90 | result['changed'] = False 91 | result['msg'] = "Batch log replay throttle is already {0} KB/s".format(value) 92 | else: 93 | 94 | if module.check_mode: 95 | result['changed'] = True 96 | result['msg'] = "Batch log replay throttle updated" 97 | else: 98 | (rc, out, err) = n.set_command() 99 | out = out.strip() 100 | if module.params['debug']: 101 | if out: 102 | result['stdout'] = out 103 | if err: 104 | result['stderr'] = err 105 | if rc != 0: 106 | result['changed'] = False 107 | module.fail_json(name=set_cmd, 108 | msg="{0} command failed".format(set_cmd), **result) 109 | else: 110 | result['changed'] = True 111 | result['msg'] = "Batch log replay throttle updated" 112 | 113 | module.exit_json(**result) 114 | 115 | 116 | if __name__ == '__main__': 117 | main() 118 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_cleanup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_cleanup 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Runs cleanup on a Cassandra node. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Runs cleanup on a Cassandra node. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | keyspace: 25 | description: 26 | - Optional keyspace. 27 | type: str 28 | table: 29 | description: 30 | - Optional table name or list of table names. 31 | type: raw 32 | num_jobs: 33 | description: 34 | - Number of job threads. 35 | type: int 36 | default: 2 37 | aliases: 38 | - j 39 | ''' 40 | 41 | EXAMPLES = ''' 42 | - name: Run cleanup on the Cassandra node 43 | community.cassandra.cassandra_cleanup: 44 | ''' 45 | 46 | RETURN = ''' 47 | cassandra_cleanup: 48 | description: The return state of the executed command. 49 | returned: success 50 | type: str 51 | ''' 52 | 53 | from ansible.module_utils.basic import AnsibleModule 54 | __metaclass__ = type 55 | 56 | 57 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandKeyspaceTableNumJobs 58 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 59 | 60 | 61 | def main(): 62 | argument_spec = cassandra_common_argument_spec() 63 | argument_spec.update( 64 | keyspace=dict(type='str', default=None, required=False, no_log=False), 65 | table=dict(type='raw', default=None, required=False), 66 | num_jobs=dict(type='int', default=2, aliases=['j'], required=False), 67 | ) 68 | module = AnsibleModule( 69 | argument_spec=argument_spec, 70 | supports_check_mode=False, 71 | ) 72 | 73 | cmd = 'cleanup' 74 | 75 | n = NodeToolCommandKeyspaceTableNumJobs(module, cmd) 76 | 77 | rc = None 78 | out = '' 79 | err = '' 80 | result = {} 81 | 82 | (rc, out, err) = n.run_command() 83 | out = out.strip() 84 | err = err.strip() 85 | if module.params['debug']: 86 | if out: 87 | result['stdout'] = out 88 | if err: 89 | result['stderr'] = err 90 | 91 | if rc == 0: 92 | result['changed'] = True 93 | result['msg'] = "nodetool cleanup executed successfully" 94 | module.exit_json(**result) 95 | else: 96 | result['rc'] = rc 97 | result['changed'] = False 98 | result['msg'] = "nodetool cleanup did not execute successfully" 99 | module.exit_json(**result) 100 | 101 | 102 | if __name__ == '__main__': 103 | main() 104 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_compactionthroughput.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_compactionthroughput 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Sets the compaction throughput. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Sets the compaction throughput. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | value: 25 | description: 26 | - MB value to set compaction throughput to. 27 | type: int 28 | required: True 29 | ''' 30 | 31 | EXAMPLES = ''' 32 | - name: Set compactionthroughput with module 33 | cassandra_compactionthroughput: 34 | value: 32 35 | ''' 36 | 37 | RETURN = ''' 38 | community.cassandra.cassandra_compactionthroughput: 39 | description: The return state of the executed command. 40 | returned: success 41 | type: str 42 | ''' 43 | 44 | from ansible.module_utils.basic import AnsibleModule 45 | __metaclass__ = type 46 | 47 | 48 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 49 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 50 | 51 | 52 | def main(): 53 | argument_spec = cassandra_common_argument_spec() 54 | argument_spec.update( 55 | value=dict(type='int', required=True) 56 | ) 57 | module = AnsibleModule( 58 | argument_spec=argument_spec, 59 | supports_check_mode=True, 60 | ) 61 | 62 | set_cmd = "setcompactionthroughput {0}".format(module.params['value']) 63 | get_cmd = "getcompactionthroughput" 64 | value = module.params['value'] 65 | 66 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 67 | 68 | rc = None 69 | out = '' 70 | err = '' 71 | result = {} 72 | 73 | (rc, out, err) = n.get_command() 74 | out = out.strip() 75 | 76 | if module.params['debug']: 77 | if out: 78 | result['stdout'] = out 79 | if err: 80 | result['stderr'] = err 81 | 82 | get_response = "Current compaction throughput: {0} MB/s".format(value) 83 | if get_response == out: 84 | 85 | if rc != 0: 86 | result['changed'] = False 87 | module.fail_json(name=get_cmd, 88 | msg="get command failed", **result) 89 | else: 90 | 91 | if module.check_mode: 92 | result['changed'] = True 93 | else: 94 | (rc, out, err) = n.set_command() 95 | out = out.strip() 96 | if module.params['debug']: 97 | if out: 98 | result['stdout'] = out 99 | if err: 100 | result['stderr'] = err 101 | if rc != 0: 102 | result['changed'] = False 103 | module.fail_json(name=set_cmd, 104 | msg="set command failed", **result) 105 | else: 106 | result['changed'] = True 107 | 108 | module.exit_json(**result) 109 | 110 | 111 | if __name__ == '__main__': 112 | main() 113 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_decommission.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_decommission 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Deactivates a node by streaming its data to another node. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Deactivates a node by streaming its data to another node. 19 | - Uses the nodetool ring command to determine if the node is still in the cluster. 20 | - To ensure correct function of this module please use the ip address of the node in the host parameter. 21 | 22 | extends_documentation_fragment: 23 | - community.cassandra.nodetool_module_options 24 | 25 | options: 26 | debug: 27 | description: 28 | - Add additional debug to module output. 29 | type: bool 30 | default: False 31 | ''' 32 | 33 | EXAMPLES = ''' 34 | - name: Decommission a node 35 | community.cassandra.cassandra_decommission: 36 | ''' 37 | 38 | RETURN = ''' 39 | msg: 40 | description: A message indicating what has happened. 41 | returned: on failure 42 | type: bool 43 | rc: 44 | description: Return code of the executed command. 45 | returned: always 46 | type: int 47 | ''' 48 | 49 | from ansible.module_utils.basic import AnsibleModule 50 | __metaclass__ = type 51 | 52 | 53 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandSimple 54 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 55 | 56 | 57 | def main(): 58 | argument_spec = cassandra_common_argument_spec() 59 | argument_spec.update( 60 | debug=dict(type='bool', default=False), 61 | ) 62 | module = AnsibleModule( 63 | argument_spec=argument_spec, 64 | supports_check_mode=True, 65 | ) 66 | 67 | debug = module.params['debug'] 68 | 69 | result = {} 70 | 71 | cmd = "ring" 72 | 73 | rc = None 74 | out = '' 75 | err = '' 76 | result = {} 77 | 78 | n = NodeToolCommandSimple(module, cmd) 79 | 80 | (rc, out, err) = n.run_command() 81 | out = out.strip() 82 | err = err.strip() 83 | if module.params['debug']: 84 | if out: 85 | result['stdout'] = out 86 | if err: 87 | result['stderr'] = err 88 | 89 | if rc == 0: 90 | if module.params['host'] in out: # host is still in ring 91 | cmd = "decommission" 92 | n = NodeToolCommandSimple(module, cmd) 93 | if not module.check_mode: 94 | (rc, out, err) = n.run_command() 95 | out = out.strip() 96 | err = err.strip() 97 | if module.params['debug']: 98 | if out: 99 | result['stdout'] = out 100 | if err: 101 | result['stderr'] = err 102 | if rc == 0: 103 | result['changed'] = True 104 | result['msg'] = "decommission command succeeded" 105 | else: 106 | result['msg'] = "decommission command failed" 107 | result['rc'] = rc 108 | module.fail_json(**result) 109 | else: 110 | result['changed'] = True 111 | result['msg'] = "decommission command succeeded" 112 | else: 113 | result['changed'] = False 114 | result['msg'] = "Node appears to be already decommissioned" 115 | module.exit_json(**result) 116 | else: 117 | result['msg'] = "decommission command failed" 118 | result['rc'] = rc 119 | module.fail_json(**result) 120 | 121 | # Everything is good 122 | module.exit_json(**result) 123 | 124 | 125 | if __name__ == '__main__': 126 | main() 127 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_drain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_drain 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Drains a Cassandra node. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Flushes all memtables from the node to SSTables on disk. 19 | - Cassandra stops listening for connections from the client and other nodes. 20 | - Restart Cassandra after running nodetool drain. 21 | - Use this command before upgrading a node to a new version of Cassandra. 22 | 23 | extends_documentation_fragment: 24 | - community.cassandra.nodetool_module_options 25 | ''' 26 | 27 | EXAMPLES = ''' 28 | - name: Drain Cassandra Node 29 | cassandra_drain: 30 | ''' 31 | 32 | RETURN = ''' 33 | community.cassandra.cassandra_drain: 34 | description: The return state of the executed command. 35 | returned: success 36 | type: str 37 | ''' 38 | 39 | from ansible.module_utils.basic import AnsibleModule 40 | __metaclass__ = type 41 | 42 | 43 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandSimple 44 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 45 | 46 | 47 | def main(): 48 | argument_spec = cassandra_common_argument_spec() 49 | module = AnsibleModule( 50 | argument_spec=argument_spec, 51 | supports_check_mode=False, 52 | ) 53 | 54 | cmd = 'drain' 55 | 56 | n = NodeToolCommandSimple(module, cmd) 57 | 58 | rc = None 59 | out = '' 60 | err = '' 61 | result = {} 62 | 63 | (rc, out, err) = n.run_command() 64 | out = out.strip() 65 | if module.params['debug']: 66 | if out: 67 | result['stdout'] = out 68 | if err: 69 | result['stderr'] = err 70 | 71 | if rc == 0: 72 | result['changed'] = True 73 | result['msg'] = "nodetool drain executed successfully" 74 | module.exit_json(**result) 75 | else: 76 | result['rc'] = rc 77 | result['changed'] = False 78 | result['msg'] = "nodetool drain did not execute successfully" 79 | module.exit_json(**result) 80 | 81 | 82 | if __name__ == '__main__': 83 | main() 84 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_flush.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_flush 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Flushes one or more tables from the memtable to SSTables on disk. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Flushes one or more tables from the memtable to SSTables on disk. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | keyspace: 25 | description: 26 | - Optional keyspace. 27 | type: str 28 | table: 29 | description: 30 | - Optional table name or list of table names. 31 | type: raw 32 | ''' 33 | 34 | EXAMPLES = ''' 35 | - name: Run flush on the Cassandra node 36 | community.cassandra.cassandra_flush: 37 | ''' 38 | 39 | RETURN = ''' 40 | cassandra_flush: 41 | description: The return state of the executed command. 42 | returned: success 43 | type: str 44 | ''' 45 | 46 | from ansible.module_utils.basic import AnsibleModule 47 | __metaclass__ = type 48 | 49 | 50 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandKeyspaceTable 51 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 52 | 53 | 54 | def main(): 55 | argument_spec = cassandra_common_argument_spec() 56 | argument_spec.update( 57 | keyspace=dict(type='str', default=None, required=False, no_log=False), 58 | table=dict(type='raw', default=None, required=False) 59 | ) 60 | module = AnsibleModule( 61 | argument_spec=argument_spec, 62 | supports_check_mode=False, 63 | ) 64 | 65 | cmd = 'flush' 66 | 67 | n = NodeToolCommandKeyspaceTable(module, cmd) 68 | 69 | rc = None 70 | out = '' 71 | err = '' 72 | result = {} 73 | 74 | (rc, out, err) = n.run_command() 75 | out = out.strip() 76 | err = err.strip() 77 | if module.params['debug']: 78 | if out: 79 | result['stdout'] = out 80 | if err: 81 | result['stderr'] = err 82 | 83 | if rc == 0: 84 | result['changed'] = True 85 | result['msg'] = "nodetool flush executed successfully" 86 | module.exit_json(**result) 87 | else: 88 | result['rc'] = rc 89 | result['changed'] = False 90 | result['msg'] = "nodetool flush did not execute successfully" 91 | module.exit_json(**result) 92 | 93 | 94 | if __name__ == '__main__': 95 | main() 96 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_garbagecollect.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_garbagecollect 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Removes deleted data from one or more tables. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Removes deleted data from one or more tables. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | keyspace: 25 | description: 26 | - Keyspace to clean up data from. 27 | type: str 28 | table: 29 | description: 30 | - Table to clean up deleted data from. 31 | type: str 32 | granularity: 33 | description: 34 | - ROW (default) removes deleted partitions and rows. 35 | - CELL also removes overwritten or deleted cells. 36 | type: str 37 | default: "ROW" 38 | choices: 39 | - "ROW" 40 | - "CELL" 41 | jobs: 42 | description: 43 | - Number of SSTables affected simultaneously. 44 | - Set to 0 to use all compaction threads. 45 | type: int 46 | default: 2 47 | ''' 48 | 49 | EXAMPLES = ''' 50 | - name: Remove deleted data from a table 51 | community.cassandra.cassandra_garbagecollect: 52 | keyspace: mykeyspace 53 | tables: mytable 54 | ''' 55 | 56 | RETURN = ''' 57 | msg: 58 | description: A brief description of what happened. 59 | returned: success 60 | type: str 61 | ''' 62 | 63 | 64 | from ansible.module_utils.basic import AnsibleModule 65 | __metaclass__ = type 66 | 67 | 68 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCmd 69 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 70 | 71 | 72 | class NodeToolCommand(NodeToolCmd): 73 | 74 | """ 75 | Inherits from the NodeToolCmd class. Adds the following methods; 76 | - run_command 77 | 2020.01.10 - Added additonal keyspace and table params 78 | """ 79 | 80 | def __init__(self, module, cmd): 81 | NodeToolCmd.__init__(self, module) 82 | self.keyspace = module.params['keyspace'] 83 | self.table = module.params['table'] 84 | self.granularity = module.params['granularity'] 85 | self.jobs = module.params['jobs'] 86 | cmd = "{0} --granularity {1} --jobs {2}".format(cmd, 87 | self.granularity, 88 | self.jobs) 89 | if self.keyspace is not None: 90 | cmd = "{0} {1}".format(cmd, self.keyspace) 91 | if self.table is not None: 92 | cmd = "{0} {1}".format(cmd, self.table) 93 | 94 | self.cmd = cmd 95 | 96 | def run_command(self): 97 | return self.nodetool_cmd(self.cmd) 98 | 99 | 100 | def main(): 101 | argument_spec = cassandra_common_argument_spec() 102 | argument_spec.update( 103 | keyspace=dict(type='str', no_log=False), 104 | table=dict(type='str'), 105 | granularity=dict(type='str', default="ROW", choices=["ROW", "CELL"]), 106 | jobs=dict(type='int', default=2) 107 | ) 108 | module = AnsibleModule( 109 | argument_spec=argument_spec, 110 | supports_check_mode=False, 111 | ) 112 | 113 | cmd = 'garbagecollect' 114 | 115 | n = NodeToolCommand(module, cmd) 116 | 117 | rc = None 118 | out = '' 119 | err = '' 120 | result = {} 121 | 122 | (rc, out, err) = n.run_command() 123 | out = out.strip() 124 | err = err.strip() 125 | if module.params['debug']: 126 | if out: 127 | result['stdout'] = out 128 | if err: 129 | result['stderr'] = err 130 | 131 | if rc == 0: 132 | result['changed'] = True 133 | result['msg'] = "nodetool garbagecollect executed successfully" 134 | else: 135 | result['rc'] = rc 136 | result['changed'] = False 137 | result['msg'] = "nodetool garbagecollect did not execute successfully" 138 | module.exit_json(**result) 139 | 140 | 141 | if __name__ == '__main__': 142 | main() 143 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_interdcstreamthroughput.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_interdcstreamthroughput 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Sets the inter-dc stream throughput. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Sets the inter-dc stream throughput. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | value: 25 | description: 26 | - MB value to set inter-dc stream throughput to. 27 | type: int 28 | required: True 29 | ''' 30 | 31 | EXAMPLES = ''' 32 | - name: Set inter dc stream throughput to 200 33 | community.cassandra.cassandra_interdcstreamthroughput: 34 | value: 200 35 | ''' 36 | 37 | RETURN = ''' 38 | cassandra_interdcstreamthroughput: 39 | description: The return state of the executed command. 40 | returned: success 41 | type: str 42 | ''' 43 | 44 | from ansible.module_utils.basic import AnsibleModule 45 | __metaclass__ = type 46 | 47 | 48 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 49 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 50 | import re 51 | 52 | 53 | # Helper functions from ChatGPT 54 | def extract_throughput(string): 55 | match = re.search(r'(\d+(?:\.\d+)?) Mb/s', string) 56 | if match: 57 | return float(match.group(1)) 58 | else: 59 | return None 60 | 61 | 62 | def compare_throughputs(string1, string2): 63 | throughput1 = extract_throughput(string1) 64 | throughput2 = extract_throughput(string2) 65 | if throughput1 is not None and throughput2 is not None: 66 | return throughput1 == throughput2 67 | else: 68 | return False 69 | 70 | 71 | def main(): 72 | argument_spec = cassandra_common_argument_spec() 73 | argument_spec.update( 74 | value=dict(type='int', required=True) 75 | ) 76 | module = AnsibleModule( 77 | argument_spec=argument_spec, 78 | supports_check_mode=True, 79 | ) 80 | 81 | set_cmd = "setinterdcstreamthroughput {0}".format(module.params['value']) 82 | get_cmd = "getinterdcstreamthroughput" 83 | 84 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 85 | 86 | if module.params['cassandra_version'] == "4.1": 87 | get_cmd += " -d" 88 | set_cmd = "setinterdcstreamthroughput {0}".format(module.params['value']) 89 | value = module.params['value'] 90 | 91 | rc = None 92 | out = '' 93 | err = '' 94 | result = {} 95 | 96 | (rc, out, err) = n.get_command() 97 | out = out.strip() 98 | 99 | if module.params['debug']: 100 | if out: 101 | result['stdout'] = out 102 | if err: 103 | result['stderr'] = err 104 | 105 | get_response = "Current inter-datacenter stream throughput: {0} Mb/s".format(value) 106 | # if module.params['cassandra_version'] == "4.1": 107 | # get_response = "Current stream throughput: {0:.1f} Mb/s".format(value) 108 | if compare_throughputs(get_response, out): 109 | 110 | if rc != 0: 111 | result['changed'] = False 112 | module.fail_json(name=get_cmd, 113 | msg="get command failed", **result) 114 | else: 115 | 116 | if module.check_mode: 117 | result['changed'] = True 118 | else: 119 | (rc, out, err) = n.set_command() 120 | out = out.strip() 121 | if module.params['debug']: 122 | if out: 123 | result['stdout'] = out 124 | if err: 125 | result['stderr'] = err 126 | if rc != 0: 127 | result['changed'] = False 128 | module.fail_json(name=set_cmd, 129 | msg="set command failed", **result) 130 | else: 131 | result['changed'] = True 132 | 133 | module.exit_json(**result) 134 | 135 | 136 | if __name__ == '__main__': 137 | main() 138 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_maxhintwindow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_maxhintwindow 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Set the specified max hint window in ms. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Set the specified max hint window in ms. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | value: 25 | description: 26 | - MS value to set the max hint window to. 27 | type: int 28 | required: True 29 | ''' 30 | 31 | EXAMPLES = ''' 32 | - name: Set max hint window with module 33 | cassandra_maxhintwindow: 34 | value: 10800000 35 | ''' 36 | 37 | RETURN = ''' 38 | msg: 39 | description: A breif description of what happened 40 | returned: success 41 | type: str 42 | ''' 43 | 44 | from ansible.module_utils.basic import AnsibleModule 45 | __metaclass__ = type 46 | 47 | 48 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 49 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 50 | 51 | 52 | def main(): 53 | argument_spec = cassandra_common_argument_spec() 54 | argument_spec.update( 55 | value=dict(type='int', required=True) 56 | ) 57 | module = AnsibleModule( 58 | argument_spec=argument_spec, 59 | supports_check_mode=True, 60 | ) 61 | 62 | set_cmd = "setmaxhintwindow -- {0}".format(module.params['value']) 63 | get_cmd = "getmaxhintwindow" 64 | value = module.params['value'] 65 | 66 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 67 | 68 | rc = None 69 | out = '' 70 | err = '' 71 | result = {} 72 | 73 | (rc, out, err) = n.get_command() 74 | out = out.strip() 75 | 76 | if module.params['debug']: 77 | if out: 78 | result['stdout'] = out 79 | if err: 80 | result['stderr'] = err 81 | 82 | get_response = "Current max hint window: {0} ms".format(value) 83 | if get_response == out: 84 | 85 | if rc != 0: 86 | result['changed'] = False 87 | module.fail_json(name=get_cmd, 88 | msg="{0} command failed".format(get_cmd), **result) 89 | else: 90 | result['changed'] = False 91 | result['msg'] = "Max Hint Window is already {0} KB/s".format(value) 92 | else: 93 | 94 | if module.check_mode: 95 | result['changed'] = True 96 | result['msg'] = "Max Hint Window updated" 97 | else: 98 | (rc, out, err) = n.set_command() 99 | out = out.strip() 100 | if module.params['debug']: 101 | if out: 102 | result['stdout'] = out 103 | if err: 104 | result['stderr'] = err 105 | if rc != 0: 106 | result['changed'] = False 107 | module.fail_json(name=set_cmd, 108 | msg="{0} command failed".format(set_cmd), **result) 109 | else: 110 | result['changed'] = True 111 | result['msg'] = "Max Hint Window updated" 112 | 113 | module.exit_json(**result) 114 | 115 | 116 | if __name__ == '__main__': 117 | main() 118 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_reload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell rhyscampbell@bluewin.ch 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_reload 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Reloads various objects into the local node. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Reloads various objects into the local node. 19 | - Currently can reload local schema, seeds, ssl certs and triggers. 20 | 21 | extends_documentation_fragment: 22 | - community.cassandra.nodetool_module_options 23 | 24 | options: 25 | reload: 26 | description: 27 | - Object type to reload. 28 | type: str 29 | required: true 30 | choices: 31 | - localschema 32 | - seeds 33 | - ssl 34 | - triggers 35 | ''' 36 | 37 | EXAMPLES = ''' 38 | - name: Reload local schema 39 | community.cassandra.cassandra_reload: 40 | reload: localschema 41 | 42 | - name: Reload seeds 43 | community.cassandra.cassandra_reload: 44 | reload: seeds 45 | 46 | - name: Reload ssl certs 47 | community.cassandra.cassandra_reload: 48 | reload: ssl 49 | 50 | - name: Reload triggers 51 | community.cassandra.cassandra_reload: 52 | reload: triggers 53 | ''' 54 | 55 | RETURN = ''' 56 | cassandra_reload: 57 | description: The return state of the executed command. 58 | returned: success 59 | type: str 60 | ''' 61 | 62 | from ansible.module_utils.basic import AnsibleModule 63 | __metaclass__ = type 64 | 65 | 66 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandSimple 67 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 68 | 69 | 70 | def main(): 71 | reload_choices = ['localschema', 72 | 'seeds', 73 | 'ssl', 74 | 'triggers'] 75 | argument_spec = cassandra_common_argument_spec() 76 | argument_spec.update( 77 | reload=dict(type='str', choices=reload_choices, required=True) 78 | ) 79 | module = AnsibleModule( 80 | argument_spec=argument_spec, 81 | supports_check_mode=False, 82 | ) 83 | 84 | cmd = "reload{0}".format(module.params['reload']) 85 | n = NodeToolCommandSimple(module, cmd) 86 | 87 | rc = None 88 | out = '' 89 | err = '' 90 | result = {} 91 | 92 | (rc, out, err) = n.run_command() 93 | out = out.strip() 94 | err = err.strip() 95 | if module.params['debug']: 96 | if out: 97 | result['stdout'] = out 98 | if err: 99 | result['stderr'] = err 100 | 101 | if rc == 0: 102 | result['changed'] = True 103 | result['msg'] = "nodetool {0} executed successfully".format(cmd) 104 | module.exit_json(**result) 105 | else: 106 | result['rc'] = rc 107 | result['changed'] = False 108 | result['msg'] = "nodetool {0} did not execute successfully".format(cmd) 109 | module.exit_json(**result) 110 | 111 | 112 | if __name__ == '__main__': 113 | main() 114 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_stopdaemon.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_stopdaemon 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Stops the Cassandra daemon. 15 | requirements: [ nodetool ] 16 | description: 17 | - Stops the Cassandra daemon. 18 | 19 | extends_documentation_fragment: 20 | - community.cassandra.nodetool_module_options 21 | ''' 22 | 23 | EXAMPLES = ''' 24 | - name: Stops cassandra daemon. 25 | community.cassandra.cassandra_stopdaemon: 26 | ''' 27 | 28 | RETURN = ''' 29 | cassandra_stopdaemon: 30 | description: The return state of the executed command. 31 | returned: success 32 | type: str 33 | ''' 34 | 35 | from ansible.module_utils.basic import AnsibleModule 36 | __metaclass__ = type 37 | 38 | 39 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandSimple 40 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 41 | 42 | 43 | def main(): 44 | argument_spec = cassandra_common_argument_spec() 45 | module = AnsibleModule( 46 | argument_spec=argument_spec, 47 | supports_check_mode=False, 48 | ) 49 | 50 | cmd = 'stopdaemon' 51 | 52 | n = NodeToolCommandSimple(module, cmd) 53 | 54 | rc = None 55 | out = '' 56 | err = '' 57 | result = {} 58 | 59 | (rc, out, err) = n.run_command() 60 | out = out.strip() 61 | if module.params['debug']: 62 | if out: 63 | result['stdout'] = out 64 | if err: 65 | result['stderr'] = err 66 | 67 | if rc == 0: 68 | result['changed'] = True 69 | result['msg'] = "nodetool stopdaemon executed successfully" 70 | module.exit_json(**result) 71 | elif rc == 2 and out == "Cassandra has shutdown.": 72 | # 2.2 behaves a little differently 73 | result['changed'] = True 74 | result['msg'] = "nodetool stopdaemon executed successfully" 75 | module.exit_json(**result) 76 | else: 77 | result['rc'] = rc 78 | result['changed'] = False 79 | result['msg'] = "nodetool stopdaemon did not execute successfully" 80 | module.exit_json(**result) 81 | 82 | 83 | if __name__ == '__main__': 84 | main() 85 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_streamthroughput.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_streamthroughput 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Sets the stream throughput. 15 | requirements: [ nodetool ] 16 | description: 17 | - Sets the stream throughput. 18 | 19 | extends_documentation_fragment: 20 | - community.cassandra.nodetool_module_options 21 | 22 | options: 23 | value: 24 | description: 25 | - MB value to set stream throughput to. 26 | type: int 27 | required: True 28 | ''' 29 | 30 | EXAMPLES = ''' 31 | - name: Set throughput to 200 32 | community.cassandra.cassandra_streamthroughput: 33 | value: 200 34 | ''' 35 | 36 | RETURN = ''' 37 | cassandra_streamthroughput: 38 | description: The return state of the executed command. 39 | returned: success 40 | type: str 41 | ''' 42 | 43 | from ansible.module_utils.basic import AnsibleModule 44 | __metaclass__ = type 45 | 46 | 47 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 48 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 49 | import re 50 | 51 | 52 | # Helper functions from ChatGPT 53 | def extract_throughput(string): 54 | match = re.search(r'(\d+(?:\.\d+)?) Mb/s', string) 55 | if match: 56 | return float(match.group(1)) 57 | else: 58 | return None 59 | 60 | 61 | def compare_throughputs(string1, string2): 62 | throughput1 = extract_throughput(string1) 63 | throughput2 = extract_throughput(string2) 64 | if throughput1 is not None and throughput2 is not None: 65 | return throughput1 == throughput2 66 | else: 67 | return False 68 | 69 | 70 | def main(): 71 | argument_spec = cassandra_common_argument_spec() 72 | argument_spec.update( 73 | value=dict(type='int', required=True) 74 | ) 75 | module = AnsibleModule( 76 | argument_spec=argument_spec, 77 | supports_check_mode=True, 78 | ) 79 | 80 | set_cmd = "setstreamthroughput {0}".format(module.params['value']) 81 | get_cmd = "getstreamthroughput" 82 | value = module.params['value'] 83 | 84 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 85 | 86 | if module.params['cassandra_version'] == "4.1": 87 | get_cmd += " -d" 88 | set_cmd = "setstreamthroughput {0}".format(module.params['value']) 89 | value = module.params['value'] 90 | 91 | rc = None 92 | out = '' 93 | err = '' 94 | result = {} 95 | 96 | (rc, out, err) = n.get_command() 97 | out = out.strip() 98 | 99 | if module.params['debug']: 100 | if out: 101 | result['stdout'] = out 102 | if err: 103 | result['stderr'] = err 104 | 105 | get_response = "Current stream throughput: {0} Mb/s".format(value) 106 | if module.params['cassandra_version'] == "4.1": 107 | get_response = "Current stream throughput: {0:.1f} Mb/s".format(value) 108 | 109 | if compare_throughputs(get_response, out): 110 | 111 | if rc != 0: 112 | result['changed'] = False 113 | module.fail_json(name=get_cmd, 114 | msg="get command failed", **result) 115 | else: 116 | 117 | if module.check_mode: 118 | result['changed'] = True 119 | else: 120 | (rc, out, err) = n.set_command() 121 | out = out.strip() 122 | if module.params['debug']: 123 | if out: 124 | result['stdout'] = out 125 | if err: 126 | result['stderr'] = err 127 | if rc != 0: 128 | result['changed'] = False 129 | module.fail_json(name=set_cmd, 130 | msg="set command failed", **result) 131 | else: 132 | result['changed'] = True 133 | 134 | module.exit_json(**result) 135 | 136 | 137 | if __name__ == '__main__': 138 | main() 139 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_timeout.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_timeout 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Manages the timeout on the Cassandra node. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Manages the timeout. 19 | - Set the specified timeout in ms, or 0 to disable timeout. 20 | 21 | extends_documentation_fragment: 22 | - community.cassandra.nodetool_module_options 23 | 24 | options: 25 | timeout: 26 | description: 27 | - Timeout in milliseconds. 28 | type: int 29 | required: True 30 | timeout_type: 31 | description: 32 | - Type of timeout. 33 | type: str 34 | choices: 35 | - read 36 | - range 37 | - write 38 | - counterwrite 39 | - cascontention 40 | - truncate 41 | - internodeconnect 42 | - internodeuser 43 | - internodestreaminguser 44 | - misc 45 | default: read 46 | ''' 47 | 48 | EXAMPLES = ''' 49 | - name: Set read timeout to 1000 ms 50 | community.cassandra.cassandra_timeout: 51 | timeout: 1000 52 | timeout_type: read 53 | 54 | - name: Disable write timeout 55 | community.cassandra.cassandra_timeout: 56 | timeout: 0 57 | timeout_type: write 58 | ''' 59 | 60 | RETURN = ''' 61 | cassandra_timeout: 62 | description: The return state of the executed command. 63 | returned: success 64 | type: str 65 | ''' 66 | 67 | from ansible.module_utils.basic import AnsibleModule 68 | __metaclass__ = type 69 | 70 | 71 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 72 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 73 | 74 | 75 | def main(): 76 | 77 | timeout_type_choices = ['read', 'range', 'write', 'counterwrite', 'cascontention', 'truncate', 78 | 'internodeconnect', 'internodeuser', 'internodestreaminguser', 'misc'] 79 | 80 | argument_spec = cassandra_common_argument_spec() 81 | argument_spec.update( 82 | timeout=dict(type='int', required=True), 83 | timeout_type=dict(type='str', choices=timeout_type_choices, default='read') 84 | ) 85 | module = AnsibleModule( 86 | argument_spec=argument_spec, 87 | supports_check_mode=True, 88 | ) 89 | 90 | timeout = module.params['timeout'] 91 | timeout_type = module.params['timeout_type'] 92 | set_cmd = "settimeout {0} {1}".format(timeout_type, timeout) 93 | get_cmd = "gettimeout {0}".format(timeout_type) 94 | 95 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 96 | 97 | rc = None 98 | out = '' 99 | err = '' 100 | result = {} 101 | 102 | (rc, out, err) = n.get_command() 103 | out = out.strip() 104 | 105 | if module.params['debug']: 106 | if out: 107 | result['stdout'] = out 108 | if err: 109 | result['stderr'] = err 110 | 111 | get_response = "Current timeout for type {0}: {1} ms".format(timeout_type, timeout) 112 | if get_response == out: 113 | 114 | if rc != 0: 115 | module.fail_json(name=get_cmd, 116 | msg="get command failed", **result) 117 | result['changed'] = False 118 | result['msg'] = "{0} timeout unchanged".format(timeout_type) 119 | else: 120 | 121 | if module.check_mode: 122 | result['changed'] = True 123 | else: 124 | (rc, out, err) = n.set_command() 125 | out = out.strip() 126 | if module.params['debug']: 127 | if out: 128 | result['stdout'] = out 129 | if err: 130 | result['stderr'] = err 131 | if rc != 0: 132 | result['changed'] = False 133 | module.fail_json(name=set_cmd, 134 | msg="set command failed", **result) 135 | else: 136 | result['changed'] = True 137 | result['msg'] = "{0} timeout changed".format(timeout_type) 138 | 139 | module.exit_json(**result) 140 | 141 | 142 | if __name__ == '__main__': 143 | main() 144 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_traceprobability.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_traceprobability 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Sets the trace probability. 15 | requirements: [ nodetool ] 16 | description: 17 | - Sets the trace probability. 18 | 19 | extends_documentation_fragment: 20 | - community.cassandra.nodetool_module_options 21 | 22 | options: 23 | value: 24 | description: 25 | - Trace probability between 0.0 and 1.0 26 | type: float 27 | required: True 28 | ''' 29 | 30 | EXAMPLES = ''' 31 | - name: Set traceprobability to 0.9 32 | community.cassandra.cassandra_traceprobability: 33 | value: 0.9 34 | ''' 35 | 36 | RETURN = ''' 37 | cassandra_traceprobability: 38 | description: The return state of the executed command. 39 | returned: success 40 | type: str 41 | ''' 42 | 43 | from ansible.module_utils.basic import AnsibleModule 44 | __metaclass__ = type 45 | 46 | 47 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolGetSetCommand 48 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 49 | 50 | 51 | def main(): 52 | argument_spec = cassandra_common_argument_spec() 53 | argument_spec.update( 54 | value=dict(type='float', required=True) 55 | ) 56 | module = AnsibleModule( 57 | argument_spec=argument_spec, 58 | supports_check_mode=True, 59 | ) 60 | 61 | set_cmd = "settraceprobability {0}".format(module.params['value']) 62 | get_cmd = "gettraceprobability" 63 | value = module.params['value'] 64 | 65 | n = NodeToolGetSetCommand(module, get_cmd, set_cmd) 66 | 67 | rc = None 68 | out = '' 69 | err = '' 70 | result = {} 71 | 72 | (rc, out, err) = n.get_command() 73 | out = out.strip() 74 | 75 | if module.params['debug']: 76 | if out: 77 | result['stdout'] = out 78 | if err: 79 | result['stderr'] = err 80 | 81 | get_response = "Current trace probability: {0}".format(value) 82 | if get_response == out: 83 | 84 | if rc != 0: 85 | result['changed'] = False 86 | module.fail_json(name=get_cmd, 87 | msg="get command failed", **result) 88 | else: 89 | 90 | if module.check_mode: 91 | result['changed'] = True 92 | else: 93 | (rc, out, err) = n.set_command() 94 | out = out.strip() 95 | if module.params['debug']: 96 | if out: 97 | result['stdout'] = out 98 | if err: 99 | result['stderr'] = err 100 | if rc != 0: 101 | result['changed'] = False 102 | module.fail_json(name=set_cmd, 103 | msg="set command failed", **result) 104 | else: 105 | result['changed'] = True 106 | 107 | module.exit_json(**result) 108 | 109 | 110 | if __name__ == '__main__': 111 | main() 112 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_truncatehints.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2021 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_truncatehints 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Truncate all hints on the local node, or truncate hints for the endpoint(s) specified. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Truncate all hints on the local node, or truncate hints for the endpoint(s) specified. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | ''' 23 | 24 | EXAMPLES = ''' 25 | - name: Run truncatehints on the local node 26 | community.cassandra.cassandra_truncatehints: 27 | ''' 28 | 29 | RETURN = ''' 30 | cassandra_flush: 31 | description: The return state of the executed command. 32 | returned: success 33 | type: str 34 | ''' 35 | 36 | from ansible.module_utils.basic import AnsibleModule 37 | __metaclass__ = type 38 | 39 | 40 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandSimple 41 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 42 | 43 | 44 | def main(): 45 | argument_spec = cassandra_common_argument_spec() 46 | module = AnsibleModule( 47 | argument_spec=argument_spec, 48 | supports_check_mode=False) 49 | 50 | cmd = 'truncatehints' 51 | 52 | n = NodeToolCommandSimple(module, cmd) 53 | 54 | rc = None 55 | out = '' 56 | err = '' 57 | result = {} 58 | 59 | (rc, out, err) = n.run_command() 60 | out = out.strip() 61 | err = err.strip() 62 | if module.params['debug']: 63 | if out: 64 | result['stdout'] = out 65 | if err: 66 | result['stderr'] = err 67 | 68 | if rc == 0: 69 | result['changed'] = True 70 | result['msg'] = "nodetool truncatehints executed successfully" 71 | module.exit_json(**result) 72 | else: 73 | result['rc'] = rc 74 | result['changed'] = False 75 | result['msg'] = "nodetool truncatehints did not execute successfully" 76 | module.exit_json(**result) 77 | 78 | 79 | if __name__ == '__main__': 80 | main() 81 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_upgradesstables.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_upgradesstables 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Upgrade SSTables which are not on the current Cassandra version. 15 | requirements: [ nodetool ] 16 | description: 17 | - Upgrade SSTables which are not on the current Cassandra version. 18 | - Use this module when upgrading your server or changing compression options. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | keyspace: 25 | description: 26 | - Optional keyspace. 27 | type: str 28 | table: 29 | description: 30 | - Optional table name or list of table names. 31 | type: raw 32 | num_jobs: 33 | description: 34 | - Number of job threads. 35 | type: int 36 | default: 2 37 | aliases: 38 | - j 39 | ''' 40 | 41 | EXAMPLES = ''' 42 | - name: Run cleanup on the Cassandra node 43 | community.cassandra.cassandra_cleanup: 44 | ''' 45 | 46 | RETURN = ''' 47 | cassandra_cleanup: 48 | description: The return state of the executed command. 49 | returned: success 50 | type: str 51 | ''' 52 | 53 | 54 | from ansible.module_utils.basic import AnsibleModule 55 | __metaclass__ = type 56 | 57 | 58 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCommandKeyspaceTableNumJobs 59 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 60 | 61 | 62 | def main(): 63 | argument_spec = cassandra_common_argument_spec() 64 | argument_spec.update( 65 | keyspace=dict(type='str', default=None, required=False, no_log=False), 66 | table=dict(type='raw', default=None, required=False), 67 | num_jobs=dict(type='int', default=2, aliases=['j'], required=False) 68 | ) 69 | module = AnsibleModule( 70 | argument_spec=argument_spec, 71 | supports_check_mode=False, 72 | ) 73 | 74 | cmd = 'upgradesstables' 75 | 76 | n = NodeToolCommandKeyspaceTableNumJobs(module, cmd) 77 | 78 | rc = None 79 | out = '' 80 | err = '' 81 | result = {} 82 | 83 | (rc, out, err) = n.run_command() 84 | out = out.strip() 85 | err = err.strip() 86 | if module.params['debug']: 87 | if out: 88 | result['stdout'] = out 89 | if err: 90 | result['stderr'] = err 91 | 92 | if rc == 0: 93 | result['changed'] = True 94 | result['msg'] = "nodetool upgradesstables executed successfully" 95 | module.exit_json(**result) 96 | else: 97 | result['rc'] = rc 98 | result['changed'] = False 99 | result['msg'] = "nodetool upgradesstables did not execute successfully" 100 | module.exit_json(**result) 101 | 102 | 103 | if __name__ == '__main__': 104 | main() 105 | -------------------------------------------------------------------------------- /plugins/modules/cassandra_verify.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # 2019 Rhys Campbell 4 | # https://github.com/rhysmeister 5 | # GNU General Public License v3.0+ 6 | # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 7 | from __future__ import absolute_import, division, print_function 8 | 9 | 10 | DOCUMENTATION = ''' 11 | --- 12 | module: cassandra_verify 13 | author: Rhys Campbell (@rhysmeister) 14 | short_description: Checks the data checksum for one or more tables. 15 | requirements: 16 | - nodetool 17 | description: 18 | - Checks the data checksum for one or more tables. 19 | 20 | extends_documentation_fragment: 21 | - community.cassandra.nodetool_module_options 22 | 23 | options: 24 | keyspace: 25 | description: 26 | - Optional keyspace. 27 | type: str 28 | table: 29 | description: 30 | - Optional table name or list of table names. 31 | type: raw 32 | extended: 33 | description: 34 | - Extended verify. 35 | - Each cell data, beyond simply checking SSTable checksums. 36 | type: bool 37 | default: False 38 | aliases: 39 | - e 40 | ''' 41 | 42 | EXAMPLES = ''' 43 | - name: Run verify on the Cassandra node 44 | community.cassandra.cassandra_verify: 45 | keyspace: mykeyspace 46 | tables: 47 | - table1 48 | - table2 49 | ''' 50 | 51 | RETURN = ''' 52 | cassandra_verify: 53 | description: The return state of the executed command. 54 | returned: success 55 | type: str 56 | ''' 57 | 58 | 59 | from ansible.module_utils.basic import AnsibleModule 60 | __metaclass__ = type 61 | 62 | 63 | from ansible_collections.community.cassandra.plugins.module_utils.nodetool_cmd_objects import NodeToolCmd 64 | from ansible_collections.community.cassandra.plugins.module_utils.cassandra_common_options import cassandra_common_argument_spec 65 | 66 | 67 | class NodeToolCommand(NodeToolCmd): 68 | 69 | """ 70 | Inherits from the NodeToolCmd class. Adds the following methods; 71 | - run_command 72 | 2020.01.10 - Added additonal keyspace and table params 73 | """ 74 | 75 | def __init__(self, module, cmd): 76 | NodeToolCmd.__init__(self, module) 77 | self.keyspace = module.params['keyspace'] 78 | self.table = module.params['table'] 79 | self.extended = module.params['extended'] 80 | if self.extended: 81 | cmd = "{0} -e".format(cmd) 82 | if self.keyspace is not None: 83 | cmd = "{0} {1}".format(cmd, self.keyspace) 84 | if self.table is not None: 85 | if isinstance(self.table, str): 86 | cmd = "{0} {1}".format(cmd, self.table) 87 | elif isinstance(self.table, list): 88 | cmd = "{0} {1}".format(cmd, " ".join(self.table)) 89 | self.cmd = cmd 90 | 91 | def run_command(self): 92 | return self.nodetool_cmd(self.cmd) 93 | 94 | 95 | def main(): 96 | argument_spec = cassandra_common_argument_spec() 97 | argument_spec.update( 98 | keyspace=dict(type='str', default=None, required=False, no_log=False), 99 | table=dict(type='raw', default=None, required=False), 100 | extended=dict(type='bool', default=False, required=False, aliases=['e']) 101 | ) 102 | module = AnsibleModule( 103 | argument_spec=argument_spec, 104 | supports_check_mode=False, 105 | ) 106 | 107 | cmd = 'verify' 108 | 109 | n = NodeToolCommand(module, cmd) 110 | 111 | rc = None 112 | out = '' 113 | err = '' 114 | result = {} 115 | 116 | (rc, out, err) = n.run_command() 117 | out = out.strip() 118 | err = err.strip() 119 | if module.params['debug']: 120 | if out: 121 | result['stdout'] = out 122 | if err: 123 | result['stderr'] = err 124 | 125 | if rc == 0: 126 | result['changed'] = True 127 | result['msg'] = "nodetool verify executed successfully" 128 | module.exit_json(**result) 129 | else: 130 | result['rc'] = rc 131 | result['changed'] = False 132 | result['msg'] = "nodetool verify did not execute successfully" 133 | module.exit_json(**result) 134 | 135 | 136 | if __name__ == '__main__': 137 | main() 138 | -------------------------------------------------------------------------------- /requirements-2.7.txt: -------------------------------------------------------------------------------- 1 | ansible==2.9.20 2 | ansible-lint==4.2.0 3 | docker==4.3.1 4 | flake8==3.7.9 5 | molecule==2.22 6 | pytest==4.6.9 7 | python-vagrant==0.5.15 8 | # sh 1.13.1 causes molecule yamllint to fail. 9 | sh<1.13 10 | -------------------------------------------------------------------------------- /requirements-3.5.txt: -------------------------------------------------------------------------------- 1 | ansible==2.9.20 2 | ansible-lint==4.2.0 3 | docker==4.3.1 4 | flake8==3.7.9 5 | molecule==2.22 6 | pytest==5.3.4 7 | python-vagrant==0.5.15 8 | sh==1.13.1 9 | -------------------------------------------------------------------------------- /requirements-3.6.txt: -------------------------------------------------------------------------------- 1 | ansible==2.9.20 2 | ansible-lint==4.2.0 3 | docker==4.3.1 4 | flake8==3.7.9 5 | molecule==2.22 6 | pytest==5.3.4 7 | python-vagrant==0.5.15 8 | sh==1.13.1 9 | -------------------------------------------------------------------------------- /requirements-3.8.txt: -------------------------------------------------------------------------------- 1 | ansible==2.9.20 2 | ansible-lint==4.2.0 3 | docker==4.3.1 4 | flake8==3.7.9 5 | molecule==2.22 6 | pytest==5.3.4 7 | python-vagrant==0.5.15 8 | sh==1.13.1 9 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | # Based on ansible-lint config 3 | extends: default 4 | 5 | rules: 6 | braces: 7 | max-spaces-inside: 1 8 | level: error 9 | brackets: 10 | max-spaces-inside: 1 11 | level: error 12 | colons: 13 | max-spaces-after: -1 14 | level: error 15 | commas: 16 | max-spaces-after: -1 17 | level: error 18 | comments: disable 19 | comments-indentation: disable 20 | document-start: disable 21 | empty-lines: 22 | max: 3 23 | level: error 24 | hyphens: 25 | level: error 26 | indentation: disable 27 | key-duplicates: enable 28 | line-length: disable 29 | new-line-at-end-of-file: disable 30 | new-lines: 31 | type: unix 32 | trailing-spaces: disable 33 | truthy: disable 34 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/README.md: -------------------------------------------------------------------------------- 1 | cassandra_firewall 2 | ================== 3 | 4 | A simple role to install and configure firewalld with the ports commonly used by Apache Cassandra.. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should 10 | be mentioned here. For instance, if the role uses the EC2 module, it may be a 11 | good idea to mention in this section that the boto package is required. 12 | 13 | Role Variables 14 | -------------- 15 | 16 | A description of the settable variables for this role should go here, including 17 | any variables that are in defaults/main.yml, vars/main.yml, and any variables 18 | that can/should be set via parameters to the role. Any variables that are read 19 | from other roles and/or the global scope (ie. hostvars, group vars, etc.) should 20 | be mentioned here as well. 21 | 22 | Dependencies 23 | ------------ 24 | 25 | A list of other roles hosted on Galaxy should go here, plus any details in 26 | regards to parameters that may need to be set for other roles, or variables that 27 | are used from other roles. 28 | 29 | Example Playbook 30 | ---------------- 31 | 32 | Including an example of how to use your role (for instance, with variables 33 | passed in as parameters) is always nice for users too: 34 | 35 | - hosts: servers 36 | roles: 37 | - { role: cassandra_firewall, x: 42 } 38 | 39 | License 40 | ------- 41 | 42 | BSD 43 | 44 | Author Information 45 | ------------------ 46 | 47 | An optional section for the role authors to include contact information, or a 48 | website (HTML is not allowed). 49 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for cassandra_firewall 3 | open_ports: 4 | - 22/tcp # ssh 5 | - 7199/tcp # jmx 6 | - 7000/tcp # Internode communication (not used if TLS enabled) 7 | - 7001/tcp # TLS Internode communication (used if TLS enabled) 8 | - 9160/tcp # Thrift client API 9 | - 9042/tcp # CQL native transport port 10 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Rhys Campbell 4 | description: A simple role to configure firewalld based systems for Cassandra. 5 | platforms: 6 | - name: RedHat 7 | versions: 8 | - all 9 | - name: Debian 10 | versions: 11 | - all 12 | - name: Ubuntu 13 | versions: 14 | - all 15 | 16 | galaxy_tags: 17 | - cassandra 18 | - database 19 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/.travisignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ansible-collections/community.cassandra/4f25557c951f1e181236f289f6d9b9d9ad53218e/roles/cassandra_firewall/molecule/.travisignore -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | {% if item.env is defined %} 10 | {% for var, value in item.env.items() %} 11 | {% if value %} 12 | ENV {{ var }} {{ value }} 13 | {% endif %} 14 | {% endfor %} 15 | {% endif %} 16 | # Add systemd-sysv package for Debian to get systemd working (and procps for sysctl) and netbase for firewalld 17 | RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates iproute2 systemd-sysv procps netbase && apt-get clean; \ 18 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ 19 | elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ 20 | elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \ 21 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 22 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi 23 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/default/files/firewalld_fix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fix firewalld on RedHat docker instances 3 | # https://vander.host/knowledgebase/operating-systems/failed-to-load-nf_conntrack-module-when-starting-firewalld/ 4 | 5 | set -e; 6 | set -u; 7 | 8 | mkdir -p "/lib/modules/$(uname -r)"; 9 | touch "/lib/modules/$(uname -r)/modules.{builtin,order}"; 10 | 11 | for i in /sys/module/*; 12 | do 13 | echo "kernel/${i##**/}.ko"; 14 | done >> "/lib/modules/$(uname -r)/modules.builtin" 15 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | lint: 7 | name: yamllint 8 | options: 9 | config-data: 10 | line-length: disable 11 | platforms: 12 | # - name: centos_7 13 | # image: centos:7 14 | # command: /sbin/init 15 | # privileged: True 16 | - name: ubuntu_16 17 | image: ubuntu:16.04 18 | command: /sbin/init 19 | privileged: True 20 | - name: ubuntu_18 21 | image: ubuntu:18.04 22 | command: /sbin/init 23 | privileged: True 24 | # - name: debian_buster 25 | # image: debian:buster 26 | # command: /sbin/init 27 | # privileged: True 28 | # - name: debian_stretch 29 | # image: debian:stretch 30 | # command: /sbin/init 31 | # privileged: True 32 | provisioner: 33 | name: ansible 34 | lint: 35 | name: ansible-lint 36 | enabled: false 37 | verifier: 38 | name: testinfra 39 | lint: 40 | name: flake8 41 | options: 42 | ignore: 'E501' 43 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | roles: 5 | - role: cassandra_firewall 6 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | 5 | tasks: 6 | 7 | - name: Run fix firewalld script on RedHat based systems 8 | script: ../files/firewalld_fix.sh 9 | when: ansible_os_family == "RedHat" 10 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE'] 7 | ).get_hosts('all') 8 | 9 | 10 | def test_ensure_firewalld_commands(host): 11 | firewalld_commands = [ 12 | "firewall-cmd", 13 | "firewalld", 14 | "firewall-offline-cmd" 15 | ] 16 | for cmd in firewalld_commands: 17 | cmd = host.run("which {0}".format(cmd)) 18 | 19 | assert cmd.rc == 0 20 | 21 | 22 | def test_ensure_cassandra_ports_open(host): 23 | expected_output = ['22/tcp', 24 | '7000/tcp', 25 | '7001/tcp', 26 | '7199/tcp', 27 | '9042/tcp', 28 | '9160/tcp'] 29 | with host.sudo(): 30 | cmd = host.run("firewall-cmd --list-ports") 31 | 32 | # Output is not always in the same order so we need to order it ourselves 33 | assert sorted(cmd.stdout.strip().split(" ")) == expected_output 34 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/virtualbox/files/firewalld_fix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fix firewalld on RedHat docker instances 3 | # https://vander.host/knowledgebase/operating-systems/failed-to-load-nf_conntrack-module-when-starting-firewalld/ 4 | 5 | set -e; 6 | set -u; 7 | 8 | mkdir -p "/lib/modules/$(uname -r)"; 9 | touch "/lib/modules/$(uname -r)/modules.{builtin,order}"; 10 | 11 | for i in /sys/module/*; 12 | do 13 | echo "kernel/${i##**/}.ko"; 14 | done >> "/lib/modules/$(uname -r)/modules.builtin" 15 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/virtualbox/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: vagrant 6 | provider: 7 | name: virtualbox 8 | lint: 9 | name: yamllint 10 | options: 11 | config-data: 12 | line-length: disable 13 | platforms: 14 | - name: centos-7 15 | box: centos/7 16 | - name: ubuntu-16 17 | box: ubuntu/xenial64 18 | - name: ubuntu-18 19 | box: ubuntu/bionic64 20 | - name: debian-buster 21 | box: debian/buster64 22 | - name: debian-stretch 23 | box: debian/contrib-stretch64 # Standard debian/stretch64 had issues: Unable to locate package linux-headers-4.9.0-9-amd64 24 | provisioner: 25 | name: ansible 26 | lint: 27 | name: ansible-lint 28 | enabled: false 29 | verifier: 30 | name: testinfra 31 | lint: 32 | name: flake8 33 | options: 34 | ignore: 'E501' 35 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/virtualbox/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | become: yes 5 | roles: 6 | - role: cassandra_firewall 7 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/virtualbox/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | become: yes 5 | 6 | tasks: 7 | 8 | - name: Run apt-get update 9 | ansible.builtin.shell: apt-get update 10 | when: ansible_os_family == "Debian" 11 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/molecule/virtualbox/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE'] 7 | ).get_hosts('all') 8 | 9 | 10 | def test_ensure_firewalld_commands(host): 11 | firewalld_commands = [ 12 | "firewall-cmd", 13 | "firewall-offline-cmd" 14 | ] 15 | for cmd in firewalld_commands: 16 | cmd = host.run("which {0}".format(cmd)) 17 | 18 | assert cmd.rc == 0 19 | 20 | 21 | def test_ensure_cassandra_ports_open(host): 22 | expected_output = ['22/tcp', 23 | '7000/tcp', 24 | '7001/tcp', 25 | '7199/tcp', 26 | '9042/tcp', 27 | '9160/tcp'] 28 | with host.sudo(): 29 | cmd = host.run("firewall-cmd --list-ports") 30 | 31 | # Output is not always in the same order so we need to order it ourselves 32 | assert sorted(cmd.stdout.strip().split(" ")) == expected_output 33 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for cassandra_firewall 3 | - name: Include vars for os family 4 | include_vars: 5 | file: "{{ ansible_os_family }}.yml" 6 | 7 | - name: Ensure firewalld package is installed 8 | package: 9 | name: "{{ firewalld_packages }}" 10 | state: present 11 | retries: 3 12 | 13 | - name: Ensure firewalld service is started 14 | service: 15 | name: firewalld 16 | state: started 17 | enabled: yes 18 | 19 | - name: Set python3 for Debian based system 20 | set_fact: 21 | mypy: "/usr/bin/python3" 22 | when: 23 | - ansible_os_family == "Debian" 24 | 25 | - name: Ensure ports for cassandra open 26 | firewalld: 27 | port: "{{ item }}" 28 | permanent: yes 29 | immediate: yes 30 | state: enabled 31 | with_items: 32 | - "{{ open_ports }}" 33 | vars: 34 | ansible_python_interpreter: "{{ mypy | default('python') }}" 35 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | firewalld_packages: 2 | - firewalld 3 | -------------------------------------------------------------------------------- /roles/cassandra_firewall/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | firewalld_packages: 2 | - python-firewall 3 | - firewalld 4 | -------------------------------------------------------------------------------- /roles/cassandra_install/.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | # Based on ansible-lint config 3 | extends: default 4 | 5 | rules: 6 | braces: 7 | max-spaces-inside: 1 8 | level: error 9 | brackets: 10 | max-spaces-inside: 1 11 | level: error 12 | colons: 13 | max-spaces-after: -1 14 | level: error 15 | commas: 16 | max-spaces-after: -1 17 | level: error 18 | comments: disable 19 | comments-indentation: disable 20 | document-start: disable 21 | empty-lines: 22 | max: 3 23 | level: error 24 | hyphens: 25 | level: error 26 | indentation: disable 27 | key-duplicates: enable 28 | line-length: disable 29 | new-line-at-end-of-file: disable 30 | new-lines: 31 | type: unix 32 | trailing-spaces: disable 33 | truthy: disable 34 | -------------------------------------------------------------------------------- /roles/cassandra_install/README.md: -------------------------------------------------------------------------------- 1 | cassandra_install 2 | ================= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should 10 | be mentioned here. For instance, if the role uses the EC2 module, it may be a 11 | good idea to mention in this section that the boto package is required. 12 | 13 | Role Variables 14 | -------------- 15 | 16 | A description of the settable variables for this role should go here, including 17 | any variables that are in defaults/main.yml, vars/main.yml, and any variables 18 | that can/should be set via parameters to the role. Any variables that are read 19 | from other roles and/or the global scope (ie. hostvars, group vars, etc.) should 20 | be mentioned here as well. 21 | 22 | Dependencies 23 | ------------ 24 | 25 | A list of other roles hosted on Galaxy should go here, plus any details in 26 | regards to parameters that may need to be set for other roles, or variables that 27 | are used from other roles. 28 | 29 | Example Playbook 30 | ---------------- 31 | 32 | Including an example of how to use your role (for instance, with variables 33 | passed in as parameters) is always nice for users too: 34 | 35 | - hosts: servers 36 | roles: 37 | - { role: cassandra_install, x: 42 } 38 | 39 | License 40 | ------- 41 | 42 | BSD 43 | 44 | Author Information 45 | ------------------ 46 | 47 | An optional section for the role authors to include contact information, or a 48 | website (HTML is not allowed). 49 | -------------------------------------------------------------------------------- /roles/cassandra_install/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for cassandra_install 3 | cassandra_packages: cassandra 4 | -------------------------------------------------------------------------------- /roles/cassandra_install/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Rhys Campbell 4 | description: A simple role to install Cassandra for RedHat, Debian and Ubuntu platforms. 5 | platforms: 6 | - name: RedHat 7 | versions: 8 | - all 9 | - name: Debian 10 | versions: 11 | - all 12 | - name: Ubuntu 13 | versions: 14 | - all 15 | 16 | galaxy_tags: 17 | - cassandra 18 | - database 19 | -------------------------------------------------------------------------------- /roles/cassandra_install/molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | {% if item.env is defined %} 10 | {% for var, value in item.env.items() %} 11 | {% if value %} 12 | ENV {{ var }} {{ value }} 13 | {% endif %} 14 | {% endfor %} 15 | {% endif %} 16 | 17 | RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates iproute2 && apt-get clean; \ 18 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ 19 | elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ 20 | elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \ 21 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 22 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi 23 | -------------------------------------------------------------------------------- /roles/cassandra_install/molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | lint: 7 | name: yamllint 8 | options: 9 | config-data: 10 | line-length: disable 11 | platforms: 12 | #- name: centos_7 13 | # image: centos:7 14 | - name: ubuntu_16 15 | image: ubuntu:16.04 16 | - name: ubuntu_18 17 | image: ubuntu:18.04 18 | #- name: debian_buster 19 | # image: debian:buster 20 | #- name: debian_stretch 21 | # image: debian:stretch 22 | provisioner: 23 | name: ansible 24 | lint: 25 | name: ansible-lint 26 | enabled: false 27 | verifier: 28 | name: testinfra 29 | lint: 30 | name: flake8 31 | options: 32 | ignore: 'E501' 33 | -------------------------------------------------------------------------------- /roles/cassandra_install/molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | roles: 5 | - role: cassandra_repository 6 | - role: cassandra_install 7 | -------------------------------------------------------------------------------- /roles/cassandra_install/molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE'] 7 | ).get_hosts('all') 8 | 9 | 10 | def test_cassandra_available(host): 11 | cmd = host.run("cassandra -h") 12 | assert cmd.rc == 0 13 | 14 | 15 | def test_nodetool_available(host): 16 | cmd = host.run("nodetool help") 17 | assert cmd.rc == 0 18 | 19 | 20 | def test_cqlsh_available(host): 21 | cmd = host.run("cqlsh --version") 22 | assert cmd.rc == 0 23 | assert "cqlsh" in cmd.stdout 24 | -------------------------------------------------------------------------------- /roles/cassandra_install/tasks/jdk1.8_Debian_Buster.yml: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/57031649/how-to-install-openjdk-8-jdk-on-debian-10-buster 2 | - name: Install packages 3 | ansible.builtin.apt: 4 | name: "software-properties-common" 5 | 6 | - name: Add repo for OpenJDK from stretch 7 | apt_repository: 8 | repo: "deb http://security.debian.org/debian-security stretch/updates main" 9 | state: present 10 | filename: "debian-stretch-security" 11 | retries: 3 12 | 13 | - name: Install openjdk8 14 | ansible.builtin.apt: 15 | name: "openjdk-8-jdk" -------------------------------------------------------------------------------- /roles/cassandra_install/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for cassandra_install 3 | - name: For Debian Buster we need to make sure openjdk 1.8 is installed 4 | include_tasks: 5 | file: jdk1.8_Debian_Buster.yml 6 | when: 7 | - ansible_os_family == "Debian" 8 | - ansible_distribution_release == "buster" 9 | 10 | - name: Install Cassandra Packages 11 | package: 12 | name: "{{ cassandra_packages }}" 13 | state: present 14 | retries: 3 15 | 16 | # https://issues.apache.org/jira/browse/CASSANDRA-16822?orderby=created+DESC%2C+priority+DESC%2C+updated+DESC 17 | - name: Install clqshlib - bug - ImportError - No module named cqlshlib 18 | ansible.builtin.shell: cp -r /usr/lib/python3.6/site-packages/cqlshlib /usr/lib/python2.7/site-packages/cqlshlib 19 | args: 20 | creates: /usr/lib/python2.7/site-packages/cqlshlib 21 | when: 22 | - ansible_os_family == 'RedHat' 23 | - ansible_distribution_major_version == "7" 24 | - "cassandra_version.startswith('4') or cassandra_version.startswith('3')" 25 | -------------------------------------------------------------------------------- /roles/cassandra_linux/.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | # Based on ansible-lint config 3 | extends: default 4 | 5 | rules: 6 | braces: 7 | max-spaces-inside: 1 8 | level: error 9 | brackets: 10 | max-spaces-inside: 1 11 | level: error 12 | colons: 13 | max-spaces-after: -1 14 | level: error 15 | commas: 16 | max-spaces-after: -1 17 | level: error 18 | comments: disable 19 | comments-indentation: disable 20 | document-start: disable 21 | empty-lines: 22 | max: 3 23 | level: error 24 | hyphens: 25 | level: error 26 | indentation: disable 27 | key-duplicates: enable 28 | line-length: disable 29 | new-line-at-end-of-file: disable 30 | new-lines: 31 | type: unix 32 | trailing-spaces: disable 33 | truthy: disable 34 | -------------------------------------------------------------------------------- /roles/cassandra_linux/README.md: -------------------------------------------------------------------------------- 1 | cassandra_linux 2 | =============== 3 | 4 | Set Cassandra Linux OS customizations. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should 10 | be mentioned here. For instance, if the role uses the EC2 module, it may be a 11 | good idea to mention in this section that the boto package is required. 12 | 13 | Role Variables 14 | -------------- 15 | 16 | A description of the settable variables for this role should go here, including 17 | any variables that are in defaults/main.yml, vars/main.yml, and any variables 18 | that can/should be set via parameters to the role. Any variables that are read 19 | from other roles and/or the global scope (ie. hostvars, group vars, etc.) should 20 | be mentioned here as well. 21 | 22 | Dependencies 23 | ------------ 24 | 25 | A list of other roles hosted on Galaxy should go here, plus any details in 26 | regards to parameters that may need to be set for other roles, or variables that 27 | are used from other roles. 28 | 29 | Example Playbook 30 | ---------------- 31 | 32 | Including an example of how to use your role (for instance, with variables 33 | passed in as parameters) is always nice for users too: 34 | 35 | - hosts: servers 36 | roles: 37 | - { role: cassandra_linux, x: 42 } 38 | 39 | License 40 | ------- 41 | 42 | BSD 43 | 44 | Author Information 45 | ------------------ 46 | 47 | An optional section for the role authors to include contact information, or a 48 | website (HTML is not allowed). 49 | 50 | References 51 | __________ 52 | 53 | The following sources of information were used extensively for this role: 54 | 55 | * https://docs.datastax.com/en/docker/doc/docker/dockerRecommendedSettings.html 56 | * https://docs.datastax.com/en/cassandra/3.0/cassandra/install/installRecommendSettings.html 57 | * https://docs.datastax.com/en/dse/5.1/dse-admin/datastax_enterprise/config/configRecommendedSettings.html 58 | 59 | TODO 60 | ---- 61 | 62 | * Need to check the tasked marked with is_docker tests to ensure they function in a non-docker environment. 63 | -------------------------------------------------------------------------------- /roles/cassandra_linux/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for cassandra_linux 3 | ntp_packages: 4 | - "ntp" 5 | - "ntpdate" 6 | - "ntp-doc" 7 | -------------------------------------------------------------------------------- /roles/cassandra_linux/files/disable-thp.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Disable Transparent Huge Pages (THP) 3 | 4 | [Service] 5 | Type=simple 6 | ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag" 7 | 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /roles/cassandra_linux/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for cassandra_linux 3 | -------------------------------------------------------------------------------- /roles/cassandra_linux/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Rhys Campbell 4 | description: A simple role to configure a few Linux OS items for Cassandra. 5 | platforms: 6 | - name: RedHat 7 | versions: 8 | - all 9 | - name: Debian 10 | versions: 11 | - all 12 | - name: Ubuntu 13 | versions: 14 | - all 15 | 16 | galaxy_tags: 17 | - cassandra 18 | - database 19 | -------------------------------------------------------------------------------- /roles/cassandra_linux/molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | {% if item.env is defined %} 10 | {% for var, value in item.env.items() %} 11 | {% if value %} 12 | ENV {{ var }} {{ value }} 13 | {% endif %} 14 | {% endfor %} 15 | {% endif %} 16 | # Add systemd-sysv package for Debian to get systemd working (and procps for sysctl) 17 | RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates iproute2 systemd-sysv procps && apt-get clean; \ 18 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ 19 | elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ 20 | elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \ 21 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 22 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi 23 | -------------------------------------------------------------------------------- /roles/cassandra_linux/molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | lint: 7 | name: yamllint 8 | options: 9 | config-data: 10 | line-length: disable 11 | platforms: 12 | #- name: centos_7 13 | # image: centos:7 14 | # command: /sbin/init 15 | # privileged: True 16 | - name: ubuntu_16 17 | image: ubuntu:16.04 18 | command: /sbin/init 19 | privileged: True 20 | - name: ubuntu_18 21 | image: ubuntu:18.04 22 | command: /sbin/init 23 | privileged: True 24 | - name: debian_buster 25 | image: debian:buster 26 | command: /sbin/init 27 | privileged: True 28 | #- name: debian_stretch 29 | # image: debian:stretch 30 | # command: /sbin/init 31 | # privileged: True 32 | provisioner: 33 | name: ansible 34 | lint: 35 | name: ansible-lint 36 | enabled: false 37 | verifier: 38 | name: testinfra 39 | lint: 40 | name: flake8 41 | options: 42 | ignore: 'E501' 43 | -------------------------------------------------------------------------------- /roles/cassandra_linux/molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | roles: 5 | - role: cassandra_linux 6 | -------------------------------------------------------------------------------- /roles/cassandra_linux/molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | 5 | tasks: 6 | 7 | - name: Are we in docker? 8 | ansible.builtin.shell: "grep :/docker /proc/self/cgroup | wc -l" 9 | 10 | - name: Create is_docker.txt file 11 | file: 12 | path: is_docker.txt 13 | state: touch 14 | -------------------------------------------------------------------------------- /roles/cassandra_linux/molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE'] 7 | ).get_hosts('all') 8 | 9 | 10 | def test_hosts_file(host): 11 | f = host.file('/etc/hosts') 12 | 13 | assert f.exists 14 | assert f.user == 'root' 15 | assert f.group == 'root' 16 | 17 | 18 | def test_swap_off(host): 19 | 20 | f = host.file("./is_docker.txt") 21 | 22 | if f.exists is False: 23 | cmd = host.run("free | grep Swap | tr -s ' ' | cut -d ' ' -f 2") 24 | 25 | assert cmd.rc == 0 26 | assert cmd.stdout.strip() == "0" 27 | 28 | 29 | def test_swapiness_1(host): 30 | cmd = host.run("cat /proc/sys/vm/swappiness") 31 | 32 | assert cmd.rc == 0 33 | assert cmd.stdout.strip() == "1" 34 | 35 | 36 | def test_max_map_count_1048575(host): 37 | cmd = host.run("cat /proc/sys/vm/max_map_count") 38 | 39 | assert cmd.rc == 0 40 | assert cmd.stdout.strip() == "1048575" 41 | 42 | 43 | def test_ntp_is_installed(host): 44 | 45 | nginx = host.package("ntp") 46 | assert nginx.is_installed 47 | 48 | nginx = host.package("ntpdate") 49 | assert nginx.is_installed 50 | 51 | nginx = host.package("ntp-doc") 52 | assert nginx.is_installed 53 | 54 | 55 | def test_ntp_service(host): 56 | ntp_service = "ntpd" 57 | if host.system_info.distribution == "debian" \ 58 | or host.system_info.distribution == "ubuntu": 59 | ntp_service = "ntp" 60 | 61 | s = host.service(ntp_service) 62 | assert s.is_running 63 | assert s.is_enabled 64 | 65 | 66 | def test_limit_file(host): 67 | 68 | f = host.file("/etc/security/limits.conf") 69 | 70 | assert f.exists 71 | assert "cassandra" in f.content_string 72 | 73 | # Extra check for RH based system 74 | if host.system_info.distribution == "redhat" \ 75 | or host.system_info.distribution == "centos": 76 | f = host.file("/etc/security/limits.d/90-nproc.conf") 77 | 78 | assert f.exists 79 | assert "nproc" in f.content_string 80 | 81 | 82 | def test_thp_service_worked(host): 83 | 84 | cmd = host.run("cat /sys/kernel/mm/transparent_hugepage/enabled") 85 | 86 | assert cmd.rc == 0 87 | assert cmd.stdout.strip() == "always madvise [never]" 88 | -------------------------------------------------------------------------------- /roles/cassandra_linux/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for cassandra_linux 3 | - name: Include vars for OS family 4 | include_vars: 5 | file: "{{ ansible_os_family }}.yml" 6 | 7 | - name: Check is_docker.txt file exists 8 | stat: 9 | path: is_docker.txt 10 | register: is_docker 11 | 12 | - name: Disable Swap 13 | command: swapoff -a 14 | when: 15 | - is_docker.stat.exists == False 16 | - ansible_swaptotal_mb > 0 17 | 18 | - name: Remove swap partitions 19 | mount: 20 | path: swap 21 | state: absent 22 | 23 | - name: Ensure Swappiness is 1 24 | sysctl: 25 | name: vm.swappiness 26 | value: "1" 27 | sysctl_set: yes 28 | reload: yes 29 | 30 | - name: Ensure max_map_count is 1048575 31 | sysctl: 32 | name: vm.max_map_count 33 | value: "1048575" 34 | sysctl_set: yes 35 | reload: yes 36 | 37 | - name: Install ntp 38 | package: 39 | name: "{{ ntp_packages }}" 40 | state: present 41 | retries: 3 42 | 43 | - name: Ensure ntp service starts 44 | service: 45 | name: "{{ ntp_service }}" 46 | enabled: yes 47 | state: started 48 | 49 | - name: Ensure limits are set 50 | blockinfile: 51 | path: /etc/security/limits.conf 52 | block: | 53 | cassandra - memlock unlimited 54 | cassandra - nofile 100000 55 | cassandra - nproc 32768 56 | cassandra - as unlimited 57 | marker: "#" 58 | state: present 59 | 60 | - name: Extra Limit for RH Derived Distros 61 | lineinfile: 62 | path: /etc/security/limits.d/90-nproc.conf 63 | regexp: "^\\* - nproc 32768" 64 | line: "* - nproc 32768" 65 | create: yes 66 | when: ansible_os_family == "RedHat" 67 | 68 | - name: TCP setting for prevents timeouts and handling many connections 69 | sysctl: 70 | name: "{{ item.key }}" 71 | value: "{{ item.value }}" 72 | state: present 73 | sysctl_file: /etc/sysctl.conf 74 | reload: yes 75 | with_items: 76 | - { key: net.ipv4.tcp_keepalive_time, value: 60 } 77 | - { key: net.ipv4.tcp_keepalive_probes, value: 3 } 78 | - { key: net.ipv4.tcp_keepalive_intvl, value: 10 } 79 | - { key: net.core.rmem_max, value: 16777216 } 80 | - { key: net.core.wmem_max, value: 16777216 } 81 | - { key: net.core.rmem_default, value: 16777216 } 82 | - { key: net.core.wmem_default, value: 16777216 } 83 | - { key: net.core.optmem_max, value: 40960 } 84 | - { key: net.ipv4.tcp_rmem, value: "4096 87380 16777216" } 85 | - { key: net.ipv4.tcp_wmem, value: "4096 65536 16777216" } 86 | when: 87 | - is_docker.stat.exists == False 88 | 89 | - name: Disable zone_reclaim_mode 90 | sysctl: 91 | name: vm.zone_reclaim_mode 92 | value: 0 93 | state: present 94 | sysctl_file: /etc/sysctl.conf 95 | reload: yes 96 | when: 97 | - is_docker.stat.exists == False 98 | 99 | - name: Ensure disable-thp service file exists 100 | copy: 101 | src: disable-thp.service 102 | dest: /etc/systemd/system/ 103 | register: thp 104 | 105 | - name: Ensure service to disable THP exists 106 | systemd: 107 | name: disable-thp 108 | daemon-reload: yes 109 | state: started 110 | enabled: yes 111 | when: thp.changed == True 112 | -------------------------------------------------------------------------------- /roles/cassandra_linux/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | ntp_service: ntp 2 | -------------------------------------------------------------------------------- /roles/cassandra_linux/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | ntp_service: ntpd 2 | -------------------------------------------------------------------------------- /roles/cassandra_repository/.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | # Based on ansible-lint config 3 | extends: default 4 | 5 | rules: 6 | braces: 7 | max-spaces-inside: 1 8 | level: error 9 | brackets: 10 | max-spaces-inside: 1 11 | level: error 12 | colons: 13 | max-spaces-after: -1 14 | level: error 15 | commas: 16 | max-spaces-after: -1 17 | level: error 18 | comments: disable 19 | comments-indentation: disable 20 | document-start: disable 21 | empty-lines: 22 | max: 3 23 | level: error 24 | hyphens: 25 | level: error 26 | indentation: disable 27 | key-duplicates: enable 28 | line-length: disable 29 | new-line-at-end-of-file: disable 30 | new-lines: 31 | type: unix 32 | trailing-spaces: disable 33 | truthy: disable 34 | -------------------------------------------------------------------------------- /roles/cassandra_repository/README.md: -------------------------------------------------------------------------------- 1 | cassandra_repository 2 | ==================== 3 | 4 | Configures a repository for Cassandra on Debian and RedHat based platforms. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should 10 | be mentioned here. For instance, if the role uses the EC2 module, it may be a 11 | good idea to mention in this section that the boto package is required. 12 | 13 | Role Variables 14 | -------------- 15 | 16 | cassandra_version: 17 | - Which version of Cassandra to install. 18 | - Should be a version from.. 19 | - http://dl.bintray.com/apache/cassandra/dists/ 20 | - https://www.apache.org/dist/cassandra/redhat/ 21 | 22 | Dependencies 23 | ------------ 24 | 25 | A list of other roles hosted on Galaxy should go here, plus any details in 26 | regards to parameters that may need to be set for other roles, or variables that 27 | are used from other roles. 28 | 29 | Example Playbook 30 | ---------------- 31 | 32 | Including an example of how to use your role (for instance, with variables 33 | passed in as parameters) is always nice for users too: 34 | 35 | - hosts: servers 36 | roles: 37 | - { role: cassandra_repository, x: 42 } 38 | 39 | License 40 | ------- 41 | 42 | BSD 43 | 44 | Author Information 45 | ------------------ 46 | 47 | An optional section for the role authors to include contact information, or a 48 | website (HTML is not allowed). 49 | -------------------------------------------------------------------------------- /roles/cassandra_repository/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | cassandra_version: "311x" 3 | debian_packages: 4 | - apt-transport-https 5 | - curl 6 | - gnupg 7 | -------------------------------------------------------------------------------- /roles/cassandra_repository/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Rhys Campbell 4 | description: A simple role to configure a Cassandra Repository for RedHat and Debian based systems. 5 | platforms: 6 | - name: RedHat 7 | versions: 8 | - all 9 | - name: Debian 10 | versions: 11 | - all 12 | - name: Ubuntu 13 | versions: 14 | - all 15 | 16 | galaxy_tags: 17 | - cassandra 18 | - database 19 | -------------------------------------------------------------------------------- /roles/cassandra_repository/molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | {% if item.env is defined %} 10 | {% for var, value in item.env.items() %} 11 | {% if value %} 12 | ENV {{ var }} {{ value }} 13 | {% endif %} 14 | {% endfor %} 15 | {% endif %} 16 | 17 | RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates iproute2 && apt-get clean; \ 18 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ 19 | elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ 20 | elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 && zypper clean -a; \ 21 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 22 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates iproute2 && xbps-remove -O; fi 23 | -------------------------------------------------------------------------------- /roles/cassandra_repository/molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | lint: 7 | name: yamllint 8 | options: 9 | config-data: 10 | line-length: disable 11 | platforms: 12 | #- name: centos_7 13 | # image: centos:7 14 | - name: ubuntu_16 15 | image: ubuntu:16.04 16 | - name: ubuntu_18 17 | image: ubuntu:18.04 18 | - name: debian_buster 19 | image: debian:buster 20 | #- name: debian_stretch 21 | # image: debian:stretch 22 | provisioner: 23 | name: ansible 24 | lint: 25 | name: ansible-lint 26 | enabled: false 27 | verifier: 28 | name: testinfra 29 | lint: 30 | name: flake8 31 | options: 32 | ignore: 'E501' 33 | -------------------------------------------------------------------------------- /roles/cassandra_repository/molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | roles: 5 | - role: cassandra_repository 6 | -------------------------------------------------------------------------------- /roles/cassandra_repository/molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE'] 7 | ).get_hosts('all') 8 | 9 | 10 | def include_vars(host): 11 | ansible = host.ansible('include_vars', 12 | 'file="../../defaults/main.yml"', 13 | False, 14 | False) 15 | return ansible 16 | 17 | 18 | def get_cassandra_version(host): 19 | return include_vars(host)['ansible_facts']['cassandra_version'] 20 | 21 | 22 | def test_redhat_cassandra_repository_file(host): 23 | # with capsys.disabled(): #Disable autocapture of output and send to stdout N.B capsys must be passed into function 24 | # print(include_vars(host)['ansible_facts']) 25 | cassandra_version = get_cassandra_version(host) 26 | if host.system_info.distribution == "redhat" \ 27 | or host.system_info.distribution == "centos": 28 | f = host.file("/etc/yum.repos.d/cassandra-{0}.repo".format(cassandra_version)) 29 | assert f.exists 30 | assert f.user == 'root' 31 | assert f.group == 'root' 32 | assert f.mode == 0o644 33 | 34 | 35 | def test_redhat_yum_search(host): 36 | cassandra_version = get_cassandra_version(host) 37 | if host.system_info.distribution == "redhat" \ 38 | or host.system_info.distribution == "centos": 39 | cmd = host.run("yum search cassandra --disablerepo='*' \ 40 | --enablerepo='cassandra-{0}'".format(cassandra_version)) 41 | 42 | assert cmd.rc == 0 43 | assert "cassandra" in cmd.stdout 44 | 45 | 46 | def test_debian_cassandra_repository_file(host): 47 | cassandra_version = get_cassandra_version(host) 48 | if host.system_info.distribution == "debian" \ 49 | or host.system_info.distribution == "ubuntu": 50 | f = host.file("/etc/apt/sources.list.d/cassandra-{0}.list".format(cassandra_version)) 51 | 52 | assert f.exists 53 | assert f.user == 'root' 54 | assert f.group == 'root' 55 | assert f.mode == 0o644 56 | assert f.content_string.strip() == "deb https://debian.cassandra.apache.org {0} main".format(cassandra_version) 57 | 58 | 59 | def test_debian_apt_search(host): 60 | if host.system_info.distribution == "debian" \ 61 | or host.system_info.distribution == "ubuntu": 62 | cmd = host.run("apt search cassandra") 63 | 64 | assert cmd.rc == 0 65 | assert "cassandra" in cmd.stdout 66 | -------------------------------------------------------------------------------- /roles/cassandra_repository/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for cassandra_repository 3 | - name: Ensure Cassandra yum repository exists (RedHat) 4 | yum_repository: 5 | name: "cassandra-{{ cassandra_version }}" 6 | description: "Official Cassandra {{ cassandra_version }} yum repo" 7 | baseurl: "https://redhat.cassandra.apache.org/{{ cassandra_version }}/" 8 | gpgcheck: 1 9 | gpgkey: "https://downloads.apache.org/cassandra/KEYS" 10 | retries: 3 11 | when: ansible_os_family == "RedHat" 12 | 13 | 14 | - name: Install debian packages (Debian & Ubuntu) 15 | apt: 16 | name: "{{ debian_packages }}" 17 | state: present 18 | retries: 3 19 | when: ansible_os_family == "Debian" 20 | 21 | - set_fact: 22 | validate_certs: true 23 | when: 24 | - "ansible_distribution == 'Ubuntu'" 25 | - "ansible_distribution_version == '16.04'" 26 | 27 | 28 | - name: Add apt key for Cassandra repository (Debian & Ubuntu) 29 | apt_key: 30 | url: https://downloads.apache.org/cassandra/KEYS 31 | state: present 32 | retries: 3 33 | when: ansible_os_family == "Debian" 34 | 35 | - name: Ensure Cassandra apt repository exists (Debian & Ubuntu) 36 | apt_repository: 37 | repo: "deb https://debian.cassandra.apache.org {{ cassandra_version }} main" 38 | state: present 39 | filename: "cassandra-{{ cassandra_version }}" 40 | retries: 3 41 | when: ansible_os_family == "Debian" 42 | -------------------------------------------------------------------------------- /stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: '30 1 * * *' 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | 11 | - name: Close Stale Issues 12 | uses: actions/stale@v5.0.0 13 | with: 14 | exempt-issue-labels: 'nostale,bug,help-wanted,feature,pinboard' 15 | exempt-pr-labels: 'nostale,bug,help-wanted,feature' 16 | -------------------------------------------------------------------------------- /tests/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | 3 | set -o pipefail 4 | 5 | # Script Collection CI 6 | # Once working, we may move this script elsewhere - gundalow 7 | 8 | 9 | if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then 10 | stub="" 11 | 12 | # shellcheck disable=SC2086 13 | ansible-test coverage xml -v --requirements --group-by command --group-by version ${stub:+"$stub"} 14 | 15 | # upload coverage report to codecov.io 16 | # Example: tests/output/coverage/integration=grafana_team=docker-default=python-3.6=coverage.98a48352c8fc.4207.186313 17 | for file in tests/output/coverage/coverage=*.xml; do 18 | flags="${file##*/coverage=}" 19 | flags="${flags%.xml}" 20 | flags="${flags//=/,}" 21 | flags="${flags//[^a-zA-Z0-9_,]/_}" 22 | 23 | bash <(curl -s https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/codecov.sh) \ 24 | -f "${file}" \ 25 | -F "${flags}" \ 26 | -t c481ab27-5cd1-4c7d-bf2f-3f0ed4c836cc \ 27 | -X coveragepy \ 28 | -X gcov \ 29 | -X fix \ 30 | -X search \ 31 | -X xcode \ 32 | -K \ 33 | || echo "Failed to upload code coverage report to codecov.io: ${file}" 34 | done 35 | fi 36 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_assassinate/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_assassinate/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_assassinate module 2 | # (c) 2021, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Assassinate the node 22 | community.cassandra.cassandra_assassinate: 23 | ip_address: 192.168.0.1 24 | debug: true 25 | register: assass 26 | 27 | - assert: 28 | that: 29 | - "assass.msg == 'nodetool assassinate executed successfully for endpoint: 192.168.0.1'" 30 | - "assass.changed == True" 31 | 32 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 33 | when: cassandra_auth_tests == True 34 | 35 | - name: Assassinate the node - with auth 36 | community.cassandra.cassandra_assassinate: 37 | username: "{{ cassandra_admin_user }}" 38 | password: "{{ cassandra_admin_pwd }}" 39 | ip_address: 192.168.0.1 40 | debug: true 41 | register: assass 42 | 43 | - assert: 44 | that: 45 | - "assass.msg == 'nodetool assassinate executed successfully for endpoint: 192.168.0.1'" 46 | - "assass.changed == True" 47 | 48 | - name: Test login failure handling 49 | community.cassandra.cassandra_assassinate: 50 | username: "{{ cassandra_admin_user }}" 51 | password: XXXXXXXXXXXXX 52 | ip_address: 192.168.0.1 53 | debug: true 54 | register: login_status 55 | ignore_errors: yes 56 | when: cassandra_auth_tests == True 57 | 58 | - name: Assert failed login 59 | assert: 60 | that: 61 | - login_status.failed == True 62 | - "'Invalid username or password' in login_status.stderr" 63 | when: cassandra_auth_tests == True 64 | 65 | - name: Test incorrect nodetool_path handling 66 | community.cassandra.cassandra_assassinate: 67 | username: "{{ cassandra_admin_user }}" 68 | password: "{{ cassandra_admin_pwd }}" 69 | ip_address: 192.168.0.1 70 | nodetool_path: /tmp 71 | debug: true 72 | register: nodetool_path_error 73 | ignore_errors: true 74 | when: cassandra_auth_tests == True 75 | 76 | - name: Assert no such file 77 | assert: 78 | that: 79 | - "'No such file or directory' in nodetool_path_error.msg" 80 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_assassinate/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_autocompaction/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_autocompaction/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_backup/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_backup/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_batchlogreplaythrottle/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_batchlogreplaythrottle/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_binary/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_binary/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_cleanup/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_cleanup/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_compact/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_compact/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_compactionthreshold/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_compactionthreshold/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_compactionthroughput/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_compactionthroughput/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_concurrency/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_concurrency/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_cqlsh/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_cqlsh/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_decommission/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | - setup_cassandra_cluster_manager 5 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_decommission/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_decommission module 2 | # (c) 2021, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Run module tests for cassandra_decommission 22 | block: 23 | 24 | # ccm created nodes seem to number the jmx ports 7100, 7200, 7300 usw 25 | - name: Execute module against the first ccm node - check mode 26 | community.cassandra.cassandra_decommission: 27 | host: 127.0.0.1 28 | port: 7100 29 | nodetool_path: /home/cassandra/config/repository/{{ cassandra_version }}/bin 30 | debug: yes 31 | check_mode: yes 32 | register: rhys 33 | 34 | - name: Assert decommission successful 35 | assert: 36 | that: 37 | - rhys.changed 38 | - "rhys.msg == 'decommission command succeeded'" 39 | 40 | - name: Get info 41 | ansible.builtin.shell: nodetool -h 127.0.0.1 --port 7100 ring 42 | register: nodetool 43 | 44 | - name: Confirm that check mode works and the node is still in the ring 45 | assert: 46 | that: 47 | - "'127.0.0.1' in nodetool.stdout" 48 | 49 | - name: Execute module against the first ccm node 50 | community.cassandra.cassandra_decommission: 51 | host: 127.0.0.1 52 | port: 7100 53 | nodetool_path: /home/cassandra/config/repository/{{ cassandra_version }}/bin 54 | debug: yes 55 | register: rhys 56 | 57 | - name: Assert decommission successful 58 | assert: 59 | that: 60 | - rhys.changed 61 | - "rhys.msg == 'decommission command succeeded'" 62 | 63 | - name: Run module again 64 | community.cassandra.cassandra_decommission: 65 | host: 127.0.0.1 66 | port: 7100 67 | nodetool_path: /home/cassandra/config/repository/{{ cassandra_version }}/bin 68 | debug: yes 69 | register: rhys 70 | 71 | - name: Assert decommission successful 72 | assert: 73 | that: 74 | - rhys.changed == False 75 | - "rhys.msg == 'Node appears to be already decommissioned'" 76 | 77 | - name: Get info 78 | ansible.builtin.shell: nodetool -h 127.0.0.1 --port 7100 ring 79 | register: nodetool 80 | 81 | - name: Confirm that node has been decommissioned 82 | assert: 83 | that: 84 | - "'127.0.0.1' not in nodetool.stdout" 85 | 86 | # TODO - Add tests with auth 87 | #- include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 88 | # when: cassandra_auth_tests == True 89 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_decommission/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_drain/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_drain/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_gossip module 2 | # (c) 2019, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Drain the node 22 | community.cassandra.cassandra_drain: 23 | register: drain 24 | 25 | - assert: 26 | that: 27 | - "drain.msg == 'nodetool drain executed successfully'" 28 | - "drain.changed == True" 29 | 30 | - name: Restart Cassandra 31 | service: 32 | name: cassandra 33 | state: restarted 34 | 35 | - name: Wait for Cassandra to become active 36 | wait_for: 37 | port: 9042 38 | host: 0.0.0.0 39 | delay: 10 40 | 41 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 42 | when: cassandra_auth_tests == True 43 | 44 | - name: Run drain with auth 45 | community.cassandra.cassandra_drain: 46 | username: "{{ cassandra_admin_user }}" 47 | password: "{{ cassandra_admin_pwd }}" 48 | debug: yes 49 | register: drain 50 | 51 | - assert: 52 | that: 53 | - "drain.msg == 'nodetool drain executed successfully'" 54 | - "drain.changed == True" 55 | 56 | - name: Restart Cassandra 57 | service: 58 | name: cassandra 59 | state: restarted 60 | 61 | - name: Wait for Cassandra to become active 62 | wait_for: 63 | port: 9042 64 | host: 0.0.0.0 65 | delay: 10 66 | 67 | - name: Test login failure handling 68 | community.cassandra.cassandra_drain: 69 | username: "{{ cassandra_admin_user }}" 70 | password: XXXXXXXXXXXXXXXXXXXXX 71 | debug: yes 72 | register: login_status 73 | ignore_errors: yes 74 | when: cassandra_auth_tests == True 75 | 76 | - name: Assert failed login 77 | assert: 78 | that: 79 | - login_status.failed == True 80 | - "'Invalid username or password' in login_status.stderr" 81 | when: cassandra_auth_tests == True 82 | 83 | - name: Test incorrect nodetool_path handling 84 | community.cassandra.cassandra_drain: 85 | nodetool_path: /tmp 86 | debug: yes 87 | register: nodetool_path_error 88 | ignore_errors: true 89 | when: cassandra_auth_tests == True 90 | 91 | - name: Assert no such file 92 | assert: 93 | that: 94 | - "'No such file or directory' in nodetool_path_error.msg" 95 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_drain/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_flush/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_flush/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_flush module 2 | # (c) 2019, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Flush the node 22 | community.cassandra.cassandra_flush: 23 | debug: true 24 | register: flush 25 | 26 | - assert: 27 | that: 28 | - "flush.msg == 'nodetool flush executed successfully'" 29 | - "flush.changed == True" 30 | 31 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 32 | when: cassandra_auth_tests == True 33 | 34 | - name: Run flush with auth 35 | community.cassandra.cassandra_flush: 36 | username: "{{ cassandra_admin_user }}" 37 | password: "{{ cassandra_admin_pwd }}" 38 | debug: true 39 | register: flush 40 | 41 | - assert: 42 | that: 43 | - "flush.msg == 'nodetool flush executed successfully'" 44 | - "flush.changed == True" 45 | 46 | - name: Test login failure handling 47 | community.cassandra.cassandra_flush: 48 | username: "{{ cassandra_admin_user }}" 49 | password: XXXXXXXXXXXXXXXXXXXXX 50 | debug: true 51 | register: login_status 52 | ignore_errors: yes 53 | when: cassandra_auth_tests == True 54 | 55 | - name: Assert failed login 56 | assert: 57 | that: 58 | - login_status.failed == True 59 | - "'Invalid username or password' in login_status.stderr" 60 | when: cassandra_auth_tests == True 61 | 62 | - name: Test incorrect nodetool_path handling 63 | community.cassandra.cassandra_flush: 64 | nodetool_path: /tmp 65 | debug: true 66 | register: nodetool_path_error 67 | ignore_errors: true 68 | when: cassandra_auth_tests == True 69 | 70 | - name: Assert no such file 71 | assert: 72 | that: 73 | - "'No such file or directory' in nodetool_path_error.msg" 74 | 75 | - name: Run flush against system_auth keyspace 76 | community.cassandra.cassandra_flush: 77 | username: "{{ cassandra_admin_user }}" 78 | password: "{{ cassandra_admin_pwd }}" 79 | keyspace: system_auth 80 | debug: true 81 | register: flush 82 | 83 | - assert: 84 | that: 85 | - "flush.msg == 'nodetool flush executed successfully'" 86 | - "flush.changed == True" 87 | 88 | - name: Run flush against system_auth/roles (str) 89 | community.cassandra.cassandra_flush: 90 | username: "{{ cassandra_admin_user }}" 91 | password: "{{ cassandra_admin_pwd }}" 92 | keyspace: system_auth 93 | table: roles 94 | debug: true 95 | register: flush 96 | 97 | - assert: 98 | that: 99 | - "flush.msg == 'nodetool flush executed successfully'" 100 | - "flush.changed == True" 101 | 102 | - name: Run cleanup against system_auth/roles (list) 103 | community.cassandra.cassandra_flush: 104 | username: "{{ cassandra_admin_user }}" 105 | password: "{{ cassandra_admin_pwd }}" 106 | keyspace: system_auth 107 | table: 108 | - roles 109 | debug: true 110 | register: flush 111 | 112 | - assert: 113 | that: 114 | - "flush.msg == 'nodetool flush executed successfully'" 115 | - "flush.changed == True" 116 | 117 | - name: Run flush against multiple system_auth table (list) 118 | community.cassandra.cassandra_flush: 119 | username: "{{ cassandra_admin_user }}" 120 | password: "{{ cassandra_admin_pwd }}" 121 | keyspace: system_auth 122 | table: 123 | - roles 124 | - role_permissions 125 | - role_members 126 | debug: true 127 | register: flush 128 | 129 | - assert: 130 | that: 131 | - "flush.msg == 'nodetool flush executed successfully'" 132 | - "flush.changed == True" 133 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_flush/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_fullquerylog/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_fullquerylog/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_garbagecollect/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_garbagecollect/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_gossip/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_gossip/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_handoff/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_handoff/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_interdcstreamthroughput/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_interdcstreamthroughput/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_invalidatecache/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_invalidatecache/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_keyspace/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | - setup_cassandra_cluster_manager 5 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_keyspace/tasks/284.yml: -------------------------------------------------------------------------------- 1 | - name: Create a test keyspace - LOCAL_ONE consistency 2 | community.cassandra.cassandra_keyspace: 3 | name: local_keyspace 4 | state: present 5 | data_centres: 6 | zurich: 3 7 | tokyo: 3 8 | new_york: 2 9 | consistency_level: "LOCAL_ONE" 10 | register: local 11 | 12 | - assert: 13 | that: 14 | - local.changed 15 | 16 | - name: Create a test keyspace- ANY consistency 17 | community.cassandra.cassandra_keyspace: 18 | name: any_keyspace 19 | state: present 20 | data_centres: 21 | zurich: 3 22 | tokyo: 3 23 | new_york: 2 24 | register: any 25 | 26 | - assert: 27 | that: 28 | - any.changed 29 | 30 | - name: Create a test keyspace - QUORUM consistency 31 | community.cassandra.cassandra_keyspace: 32 | name: quorum_keyspace 33 | state: present 34 | data_centres: 35 | zurich: 3 36 | tokyo: 3 37 | new_york: 2 38 | consistency_level: "QUORUM" 39 | register: quorum 40 | 41 | - assert: 42 | that: 43 | - quorum.changed 44 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_keyspace/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - libpython-dev 4 | - python-requests 5 | - libev4 6 | - libev-dev 7 | - python-openssl 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_keyspace/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - python-devel 4 | - python-requests 5 | - libev 6 | - libev-devel 7 | - pyOpenSSL 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_keyspace/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_maxhintwindow/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_maxhintwindow/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_reload/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_reload/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_gossip module 2 | # (c) 2019, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Reload the local schema 22 | community.cassandra.cassandra_reload: 23 | reload: localschema 24 | debug: true 25 | register: localschema 26 | 27 | - assert: 28 | that: 29 | - "localschema.msg == 'nodetool reloadlocalschema executed successfully'" 30 | - "localschema.changed == True" 31 | 32 | - name: Reload the seeds 33 | community.cassandra.cassandra_reload: 34 | reload: seeds 35 | debug: true 36 | register: seeds 37 | when: cassandra_version[0] | int >= 4 38 | 39 | - assert: 40 | that: 41 | - "seeds.msg == 'nodetool reloadseeds executed successfully'" 42 | - "seeds.changed == True" 43 | when: cassandra_version[0] | int >= 4 44 | 45 | - name: Reload the ssl certs 46 | community.cassandra.cassandra_reload: 47 | reload: ssl 48 | debug: true 49 | register: ssl 50 | when: cassandra_version[0] | int >= 4 51 | 52 | - assert: 53 | that: 54 | - "ssl.msg == 'nodetool reloadssl executed successfully'" 55 | - "ssl.changed == True" 56 | when: cassandra_version[0] | int >= 4 57 | 58 | - name: Reload the triggers 59 | community.cassandra.cassandra_reload: 60 | reload: triggers 61 | debug: true 62 | register: triggers 63 | 64 | - assert: 65 | that: 66 | - "triggers.msg == 'nodetool reloadtriggers executed successfully'" 67 | - "triggers.changed == True" 68 | 69 | # Same tests with auth 70 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 71 | when: cassandra_auth_tests == True 72 | 73 | - name: Reload the local schema 74 | community.cassandra.cassandra_reload: 75 | username: "{{ cassandra_admin_user }}" 76 | password: "{{ cassandra_admin_pwd }}" 77 | reload: localschema 78 | debug: true 79 | register: localschema 80 | 81 | - assert: 82 | that: 83 | - "localschema.msg == 'nodetool reloadlocalschema executed successfully'" 84 | - "localschema.changed == True" 85 | 86 | - name: Reload the seeds 87 | community.cassandra.cassandra_reload: 88 | username: "{{ cassandra_admin_user }}" 89 | password: "{{ cassandra_admin_pwd }}" 90 | reload: seeds 91 | debug: true 92 | register: seeds 93 | when: cassandra_version[0] | int >= 4 94 | 95 | - assert: 96 | that: 97 | - "seeds.msg == 'nodetool reloadseeds executed successfully'" 98 | - "seeds.changed == True" 99 | when: cassandra_version[0] | int >= 4 100 | 101 | 102 | - name: Reload the ssl certs 103 | community.cassandra.cassandra_reload: 104 | username: "{{ cassandra_admin_user }}" 105 | password: "{{ cassandra_admin_pwd }}" 106 | reload: ssl 107 | debug: true 108 | register: ssl 109 | when: cassandra_version[0] | int >= 4 110 | 111 | - assert: 112 | that: 113 | - "ssl.msg == 'nodetool reloadssl executed successfully'" 114 | - "ssl.changed == True" 115 | when: cassandra_version[0] | int >= 4 116 | 117 | - name: Reload the triggers 118 | community.cassandra.cassandra_reload: 119 | username: "{{ cassandra_admin_user }}" 120 | password: "{{ cassandra_admin_pwd }}" 121 | reload: triggers 122 | debug: true 123 | register: triggers 124 | 125 | - assert: 126 | that: 127 | - "triggers.msg == 'nodetool reloadtriggers executed successfully'" 128 | - "triggers.changed == True" -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_reload/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_removenode/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | - setup_cassandra_cluster_manager 5 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_removenode/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_role/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_role/tasks/284.yml: -------------------------------------------------------------------------------- 1 | - name: Create a test role - LOCAL_ONE consistency 2 | community.cassandra.cassandra_role: 3 | name: local_role 4 | password: p4ssw0rd 5 | login: true 6 | keyspace_permissions: 7 | test_keyspace: 8 | - "ALL PERMISSIONS" 9 | state: present 10 | login_user: "{{ cassandra_admin_user }}" 11 | login_password: "{{ cassandra_admin_pwd }}" 12 | debug: yes 13 | consistency_level: "LOCAL_ONE" 14 | register: local 15 | 16 | - assert: 17 | that: 18 | - local.changed 19 | 20 | - name: Create a test role - ANY consistency 21 | community.cassandra.cassandra_role: 22 | name: any_role 23 | password: p4ssw0rd 24 | login: true 25 | keyspace_permissions: 26 | test_keyspace: 27 | - "ALL PERMISSIONS" 28 | state: present 29 | login_user: "{{ cassandra_admin_user }}" 30 | login_password: "{{ cassandra_admin_pwd }}" 31 | debug: yes 32 | consistency_level: "ANY" 33 | register: any 34 | 35 | - assert: 36 | that: 37 | - any.changed 38 | 39 | - name: Create a test role - QUORUM consistency 40 | community.cassandra.cassandra_role: 41 | name: quorum_role 42 | password: p4ssw0rd 43 | login: true 44 | keyspace_permissions: 45 | test_keyspace: 46 | - "ALL PERMISSIONS" 47 | state: present 48 | login_user: "{{ cassandra_admin_user }}" 49 | login_password: "{{ cassandra_admin_pwd }}" 50 | debug: yes 51 | consistency_level: "QUORUM" 52 | register: quorum 53 | 54 | - assert: 55 | that: 56 | - quorum.changed 57 | 58 | - name: Create a test role - SERIAL consistency 59 | community.cassandra.cassandra_role: 60 | name: serial_role 61 | password: p4ssw0rd 62 | login: true 63 | keyspace_permissions: 64 | test_keyspace: 65 | - "ALL PERMISSIONS" 66 | state: present 67 | login_user: "{{ cassandra_admin_user }}" 68 | login_password: "{{ cassandra_admin_pwd }}" 69 | debug: yes 70 | consistency_level: "SERIAL" 71 | register: serial 72 | 73 | - assert: 74 | that: 75 | - serial.changed 76 | 77 | - name: Create a test role - LOCAL_QUORUM consistency 78 | community.cassandra.cassandra_role: 79 | name: local_quorum_role 80 | password: p4ssw0rd 81 | login: true 82 | keyspace_permissions: 83 | test_keyspace: 84 | - "ALL PERMISSIONS" 85 | state: present 86 | login_user: "{{ cassandra_admin_user }}" 87 | login_password: "{{ cassandra_admin_pwd }}" 88 | debug: yes 89 | consistency_level: "LOCAL_QUORUM" 90 | register: local_quorum 91 | 92 | - assert: 93 | that: 94 | - local_quorum.changed 95 | 96 | - name: Create a test role - TWO consistency 97 | community.cassandra.cassandra_role: 98 | name: two_role 99 | password: p4ssw0rd 100 | login: true 101 | keyspace_permissions: 102 | test_keyspace: 103 | - "ALL PERMISSIONS" 104 | state: present 105 | login_user: "{{ cassandra_admin_user }}" 106 | login_password: "{{ cassandra_admin_pwd }}" 107 | debug: yes 108 | consistency_level: "TWO" 109 | register: two 110 | ignore_errors: true 111 | 112 | - assert: 113 | that: 114 | - two.failed 115 | - "'Cannot achieve consistency level TWO' in two.msg" 116 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_role/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - libpython-dev 4 | - python-requests 5 | - libev4 6 | - libev-dev 7 | - python-openssl 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_role/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - python-devel 4 | - python-requests 5 | - libev 6 | - libev-devel 7 | - pyOpenSSL 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_role/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_schema/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | - setup_cassandra_cluster_manager 5 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_schema/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_schema module 2 | # (c) 2019, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Run module tests for cassandra_schema 22 | block: 23 | - name: Include vars from 24 | include_vars: 25 | file: ../setup_cassandra_cluster_manager/defaults/main.yml 26 | 27 | # ccm created nodes seem to number the jmx ports 7100, 7200, 7300 usw 28 | - name: Execute module against the first ccm node 29 | community.cassandra.cassandra_schema: 30 | host: 127.0.0.1 31 | port: 7100 32 | nodetool_path: /home/cassandra/config/repository/{{ cassandra_version }}/bin 33 | debug: yes 34 | register: rhys 35 | 36 | - name: Check schema agreement 37 | assert: 38 | that: 39 | - "rhys.msg == 'The cluster has reached schema consensus'" 40 | always: 41 | - name: Cleanup any ccm stuff 42 | ansible.builtin.shell: "sudo -E -u cassandra bash -c \"ccm stop test && ccm remove test > /dev/null\"" 43 | become_user: cassandra 44 | args: 45 | chdir: /home/cassandra 46 | environment: 47 | CCM_CONFIG_DIR: "/home/cassandra/config" 48 | CASSANDRA_HOME: "/home/cassandra" 49 | ignore_errors: yes 50 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_schema/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/cassandra.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDczCCAlugAwIBAgIEfxTaWTANBgkqhkiG9w0BAQsFADBqMQswCQYDVQQGEwJU 3 | RTELMAkGA1UECBMCQ0ExFDASBgNVBAcTC1NhbnRhIENsYXJhMREwDwYDVQQKEwhE 4 | YXRhU3RheDELMAkGA1UECxMCVEUxGDAWBgNVBAMTD1BoaWxpcCBUaG9tcHNvbjAe 5 | Fw0xNjAyMDgwMTMyMThaFw0xODAyMDcwMTMyMThaMGoxCzAJBgNVBAYTAlRFMQsw 6 | CQYDVQQIEwJDQTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExETAPBgNVBAoTCERhdGFT 7 | dGF4MQswCQYDVQQLEwJURTEYMBYGA1UEAxMPUGhpbGlwIFRob21wc29uMIIBIjAN 8 | BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgh3t98zq+vlHPoxD+opzknJ8+32B 9 | kPYH5OsgJYPgG5DHsJifZ9wg4z1eMdhNHMXGhpjDC/2a9RP+zgLIrz2qiF80k3U7 10 | 4YcthzFOjjQe6otHefZRrm/wWN9roEzuX+jDTHshywrWqk6n8AQ1P2XAyQ+JXqE/ 11 | 8g3kp13ISw+iyn06OGCzGpS8sXMyjM8dqyEXMYXRgVcsGyhnOry0AUub0SRYIGIX 12 | n8cO9THSMAfyazjP17JopYjBnbGx4q3+G7AIQ7LV/Po2k2/xuGPErJq5EY+8kovL 13 | 5XbOgSOJwWe6wN9jpdXZCI8Uu1nvpDnPSrQ8ULZYNvxIsHyfawlV1q16DwIDAQAB 14 | oyEwHzAdBgNVHQ4EFgQUL/pt5vT63nQ4isRbjmFQmjE+gXMwDQYJKoZIhvcNAQEL 15 | BQADggEBAD47rYXdiTYbUECvD5x76IpEmxyuRRjEDtaoiP+i5pd7SLGGwTaWy7N2 16 | h3vjawbW+NNHdSQPReoZ6aihyS0hKo3kInhClScgMsdAWgjp+TUTRvJ+w8K2QfL6 17 | Kv5NJM462H0nGC0Hd7jk7B++GyhjrPGluUnV+FiyjiEHOKNpTxAmUjUUgTSJXCTL 18 | 71BSrwOL3TYk5QbVQMsVAfLSoQjYkbb0SRSWOBnrXglq4MWP4fiJ180pae/pK73O 19 | FQqUL1jANHw4lNQfKxLKpoTNzcO+a9pbOF3CXuVueETvmvj9KcU1ksWEgMY4i8XP 20 | ZmcxuiAEQ+kL+EXyeHFV8vU3LfI0Vwo= 21 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/cassandra.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDczCCAlugAwIBAgIEfxTaWTANBgkqhkiG9w0BAQsFADBqMQswCQYDVQQGEwJU 3 | RTELMAkGA1UECBMCQ0ExFDASBgNVBAcTC1NhbnRhIENsYXJhMREwDwYDVQQKEwhE 4 | YXRhU3RheDELMAkGA1UECxMCVEUxGDAWBgNVBAMTD1BoaWxpcCBUaG9tcHNvbjAe 5 | Fw0xNjAyMDgwMTMyMThaFw0xODAyMDcwMTMyMThaMGoxCzAJBgNVBAYTAlRFMQsw 6 | CQYDVQQIEwJDQTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExETAPBgNVBAoTCERhdGFT 7 | dGF4MQswCQYDVQQLEwJURTEYMBYGA1UEAxMPUGhpbGlwIFRob21wc29uMIIBIjAN 8 | BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgh3t98zq+vlHPoxD+opzknJ8+32B 9 | kPYH5OsgJYPgG5DHsJifZ9wg4z1eMdhNHMXGhpjDC/2a9RP+zgLIrz2qiF80k3U7 10 | 4YcthzFOjjQe6otHefZRrm/wWN9roEzuX+jDTHshywrWqk6n8AQ1P2XAyQ+JXqE/ 11 | 8g3kp13ISw+iyn06OGCzGpS8sXMyjM8dqyEXMYXRgVcsGyhnOry0AUub0SRYIGIX 12 | n8cO9THSMAfyazjP17JopYjBnbGx4q3+G7AIQ7LV/Po2k2/xuGPErJq5EY+8kovL 13 | 5XbOgSOJwWe6wN9jpdXZCI8Uu1nvpDnPSrQ8ULZYNvxIsHyfawlV1q16DwIDAQAB 14 | oyEwHzAdBgNVHQ4EFgQUL/pt5vT63nQ4isRbjmFQmjE+gXMwDQYJKoZIhvcNAQEL 15 | BQADggEBAD47rYXdiTYbUECvD5x76IpEmxyuRRjEDtaoiP+i5pd7SLGGwTaWy7N2 16 | h3vjawbW+NNHdSQPReoZ6aihyS0hKo3kInhClScgMsdAWgjp+TUTRvJ+w8K2QfL6 17 | Kv5NJM462H0nGC0Hd7jk7B++GyhjrPGluUnV+FiyjiEHOKNpTxAmUjUUgTSJXCTL 18 | 71BSrwOL3TYk5QbVQMsVAfLSoQjYkbb0SRSWOBnrXglq4MWP4fiJ180pae/pK73O 19 | FQqUL1jANHw4lNQfKxLKpoTNzcO+a9pbOF3CXuVueETvmvj9KcU1ksWEgMY4i8XP 20 | ZmcxuiAEQ+kL+EXyeHFV8vU3LfI0Vwo= 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/client_cert.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: client 3 | localKeyID: 54 69 6D 65 20 31 34 35 34 38 39 35 31 34 30 35 36 32 4 | subject=/C=TE/ST=CA/L=Santa Clara/O=DataStax/OU=TE/CN=Philip Thompson 5 | issuer=/C=TE/ST=CA/L=Santa Clara/O=DataStax/OU=TE/CN=Philip Thompson 6 | -----BEGIN CERTIFICATE----- 7 | MIIDczCCAlugAwIBAgIEcXcM5DANBgkqhkiG9w0BAQsFADBqMQswCQYDVQQGEwJU 8 | RTELMAkGA1UECBMCQ0ExFDASBgNVBAcTC1NhbnRhIENsYXJhMREwDwYDVQQKEwhE 9 | YXRhU3RheDELMAkGA1UECxMCVEUxGDAWBgNVBAMTD1BoaWxpcCBUaG9tcHNvbjAe 10 | Fw0xNjAyMDgwMTMyMjBaFw0xODAyMDcwMTMyMjBaMGoxCzAJBgNVBAYTAlRFMQsw 11 | CQYDVQQIEwJDQTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExETAPBgNVBAoTCERhdGFT 12 | dGF4MQswCQYDVQQLEwJURTEYMBYGA1UEAxMPUGhpbGlwIFRob21wc29uMIIBIjAN 13 | BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhbUk95AEcexCz2xwn22cDR1SBepp 14 | WUEG8H49C0S9QG8o4DX6vPJaKDCESLNWQxuOd30KGlY19nPwPuhikAdnCohzxj+l 15 | JrEAMSmCugi6g95xne+tHx+zIIR1pvJ+YtAw11OulZNcZArt1FWniPjKz4OTFnEl 16 | otrj6W4cLz9TMiFrvvDCqwnJv9Y8Wi5jgW7zoLhGWX/TYZUimSFRAKxo7mwiAMUb 17 | u9WPTt+zmP3n5/oHhdnnnjP84Wrdq0aaZ6K6KwsuGdnuXub22XRD82FT2EWrYLoM 18 | GjwzwOQ7ldtCYy6AjKpQIQxiI2U/X1fvW50XKocNmJzbBIt46QmCZktaJwIDAQAB 19 | oyEwHzAdBgNVHQ4EFgQURNY1taeNOSYhMNYjkv/n0Thmvc4wDQYJKoZIhvcNAQEL 20 | BQADggEBAFfPD3i0Csu99AqCeHWZGII93Px9uuGryYkwTBh2n82Vcwn12LjvhrdJ 21 | CR/UN2eSnfZdg3kK8791TLm5pBqVXbsR+Melmj1ocjNJdIqqrD6UuCoJMMPi21k2 22 | IT6vnsiMsB+yHP88N/klf5Uc8G6Mz/949GccY00dd756Hmp1rnkjoa0bo2pqOFQh 23 | xQSEVF0fyvbsXoJeS7AZoIlAAHciUOd/Sd9V6tZ43BC97Vwn+UR2+sH6v8Vxd13L 24 | q1/+JDXi9PwDtw1kECjpH4HPiY/ei9r1fuy+Lp8OC34dPWZtJ31xsh5jWrthhKaz 25 | AqOccZ9cDUNECWTMXHCfcB+w0cU9ONM= 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/client_key.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: client 3 | localKeyID: 54 69 6D 65 20 31 34 35 34 38 39 35 31 34 30 35 36 32 4 | Key Attributes: 5 | -----BEGIN PRIVATE KEY----- 6 | MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCFtST3kARx7ELP 7 | bHCfbZwNHVIF6mlZQQbwfj0LRL1AbyjgNfq88looMIRIs1ZDG453fQoaVjX2c/A+ 8 | 6GKQB2cKiHPGP6UmsQAxKYK6CLqD3nGd760fH7MghHWm8n5i0DDXU66Vk1xkCu3U 9 | VaeI+MrPg5MWcSWi2uPpbhwvP1MyIWu+8MKrCcm/1jxaLmOBbvOguEZZf9NhlSKZ 10 | IVEArGjubCIAxRu71Y9O37OY/efn+geF2eeeM/zhat2rRppnororCy4Z2e5e5vbZ 11 | dEPzYVPYRatgugwaPDPA5DuV20JjLoCMqlAhDGIjZT9fV+9bnRcqhw2YnNsEi3jp 12 | CYJmS1onAgMBAAECggEABqezhVb3wavez3A4Utcj00tIT98RC04/SC0gYLU1LkXa 13 | JP7K0ijF8AYqL2wtuP1gI/ZnUFRGL1Qp+xeaAE0+Bbow+Qcl8z0QI2JLjXLtxa6G 14 | vTO2zDvJsK6nJH4haE2wgKc7o1pIWPpqSA1TX2/yuE12PsG2+9olSfMfGALw4yfQ 15 | RyC4HFCJdFZ3sPvwtbBxX60ZsZAanRMy22+iRJQ9qGLdf3rndEjkR70Ls/wOLcox 16 | TJM6/98rvIxnMuDLhNYnQdjqLa5gICPtxzVdELzoKqFPDI1zKNZAX9fOINRwMKqr 17 | Wt0fUyv2crqrJ8nQlRdsRGYxGJT5NRlbrzJz0XLUMQKBgQC9BFwJjLJBZZP87WVb 18 | /kWleWeDPvuraTJkxnXcLLnHxb/CEK23wq93katCMv5TSIiUlaUoHzK46yBJOPgB 19 | 7DvpZ+F8ub0soYOeSBtMtYgsdYI5OQOy+qxPgAy6V8Xq8qvPeGZa1t4bLQ3m+o8a 20 | wbA8vC1sxFJEVWfpo1dhA4whOwKBgQC1FxvEftIiu0P41iI0vt9LUag82gWiJhNT 21 | Wt8ee9qYokaEe3B4SNtWAJfXf3HVdYGHwOt7Shiu34V1lP7UT/MhIBGtFz1rXzVd 22 | B8MMbE9uDbufhvJ8aqJ5g4kHFCGBGpYnJh8O2dql3j0kZ4ia7Rzu2YRcVZ68MQ53 23 | NsYkOADcBQKBgA3CmnyrfHKcVXitQ5q92Q4h13JLjIC/CMcjV4Mu0luDvuD+29ar 24 | 2qBGv4PzOGaRujeu6TYRh1zE6TXLauqg6v+j61tsHiR4oZ9NOoeME5zA9Tj7OJS4 25 | AQFMniCWsTbYcb+J0VG9oK+zyPZOuUpGXXEedeQcKq0E1qrAlGTgoDvvAoGABobQ 26 | r2JKvIm3R26gSPpgHdzRjW/mKBPrOmPaCsU3+axPklLImO03SoA2+MNVHPZhNr1T 27 | P1xKS3Mu4i/+hzRidN0tBeoCgq4pxDKVaws0SakhC/zXHHjTZkHBXInzMy38H2kW 28 | UXi0kqnR1lAM8lh9ZHZeeN11HR8/gDhvJ7sE/OkCgYAYS0QLA00gDNM0J5+8+4KH 29 | ET2SUlWKBv+vWAj9mXVLdg+7KS4HIHR715vAyIV7HNVXohj9LbWYsMG2RGkbCqYO 30 | Hrrqnulet09T9Z+HD008s9xGnGFU9necujIQV0uHz1j4lCnOgVoN2NiwtU8H0dI4 31 | SumcCsPe4DQ6Y5TTU1WIlg== 32 | -----END PRIVATE KEY----- 33 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ansible-collections/community.cassandra/4f25557c951f1e181236f289f6d9b9d9ad53218e/tests/integration/targets/cassandra_ssl/files/keystore.jks -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/ssl-test.cer.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: ssl-cluster 3 | localKeyID: 54 69 6D 65 20 31 36 38 35 39 35 35 35 39 32 37 35 32 4 | subject=/C=UK/ST=Cassandra/L=Cassandra/O=Cassandra/OU=Cassandra/CN=cassandra-ssl-cluster 5 | issuer=/C=UK/ST=Cassandra/L=Cassandra/O=Cassandra/OU=Cassandra/CN=cassandra-ssl-cluster 6 | -----BEGIN CERTIFICATE----- 7 | MIIDmzCCAoOgAwIBAgIEEfyYsjANBgkqhkiG9w0BAQsFADB9MQswCQYDVQQGEwJV 8 | SzESMBAGA1UECBMJQ2Fzc2FuZHJhMRIwEAYDVQQHEwlDYXNzYW5kcmExEjAQBgNV 9 | BAoTCUNhc3NhbmRyYTESMBAGA1UECxMJQ2Fzc2FuZHJhMR4wHAYDVQQDExVjYXNz 10 | YW5kcmEtc3NsLWNsdXN0ZXIwIBcNMjMwNjA1MDg1NTAxWhgPMjEyMzA1MTIwODU1 11 | MDFaMH0xCzAJBgNVBAYTAlVLMRIwEAYDVQQIEwlDYXNzYW5kcmExEjAQBgNVBAcT 12 | CUNhc3NhbmRyYTESMBAGA1UEChMJQ2Fzc2FuZHJhMRIwEAYDVQQLEwlDYXNzYW5k 13 | cmExHjAcBgNVBAMTFWNhc3NhbmRyYS1zc2wtY2x1c3RlcjCCASIwDQYJKoZIhvcN 14 | AQEBBQADggEPADCCAQoCggEBALMRzL5PNrEMIs954K7UcuAmLk9f+KajK5AuJOsv 15 | Oph8WtF6NlmXJ1AWA3mghCQxhWyKcmdghDti67Wn477NQ4lVGffFQiqddJI8IbWK 16 | SqSSKCkM/u6WwtB5/bVz9To5asnXtuX4NwpVtl7K8e/qUIk4+XaCphrOGCyWJILF 17 | jG0SIThgMShvEtHe5oIUN1xJzP+uL0f/B2mtqK3SrwUuO8icr41zSgFSqSFtFVsl 18 | eJ59UPRLgJmQdbkzy6voZyd9e9jbxRBPHqSgoOpDakI9SSmEgwkGdBCbvjSWzrVR 19 | hj9sbkAkRCmMcimkOBxi4VoYb3zfagwojsPELkFO3BoGgi0CAwEAAaMhMB8wHQYD 20 | VR0OBBYEFKygH13FJR226AdInzfeWRJ+0fbhMA0GCSqGSIb3DQEBCwUAA4IBAQA+ 21 | u3iPk3DYQBcRNjPI8Zc/QeqQuzA6/JUvAnSreHQJMbJg5ri2mep0RvZRNaa3kXBC 22 | wrVk0Vsn3micn63DMUqToeyVLymScMkyAqwIqq/UM1ln0mWec7UCV64EkON5aXb7 23 | 8q/4wqER9ywzDPktBy9sU++tQNMl3RMg1AdHdNQLZ/X1n+1KJtX9DDAnu1D0jH5W 24 | 4KtVJLchpV7NzaKf6pmSIjT7vxgW81a8MhXIyJ5UtCtL1Q0Lxk47Ld/q/vraXRjl 25 | Pc7Z5IPJRQr8GsIFBIUMC5gNkTPOJTYGgbZijk8qAjVJlJz8IYkdfRvc91SKSF7+ 26 | l7sshI+GwEo4Yej4JtCI 27 | -----END CERTIFICATE----- 28 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/ssl-test.key.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: ssl-cluster 3 | localKeyID: 54 69 6D 65 20 31 36 38 35 39 35 35 35 39 32 37 35 32 4 | Key Attributes: 5 | -----BEGIN PRIVATE KEY----- 6 | MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCzEcy+TzaxDCLP 7 | eeCu1HLgJi5PX/imoyuQLiTrLzqYfFrRejZZlydQFgN5oIQkMYVsinJnYIQ7Yuu1 8 | p+O+zUOJVRn3xUIqnXSSPCG1ikqkkigpDP7ulsLQef21c/U6OWrJ17bl+DcKVbZe 9 | yvHv6lCJOPl2gqYazhgsliSCxYxtEiE4YDEobxLR3uaCFDdcScz/ri9H/wdprait 10 | 0q8FLjvInK+Nc0oBUqkhbRVbJXiefVD0S4CZkHW5M8ur6GcnfXvY28UQTx6koKDq 11 | Q2pCPUkphIMJBnQQm740ls61UYY/bG5AJEQpjHIppDgcYuFaGG9832oMKI7DxC5B 12 | TtwaBoItAgMBAAECggEAGnn1ReY8de0PcJHasL7kxVOf4UiVYT4bANRxzPxMs6Mf 13 | Yn2pb5Gz1FmM5fzfzOItkiDeTX6tzoIPy+oo+FstMy8MCeB2qgph5AVUDp2F79NU 14 | cM1lHC3aXCzNYHjmt1cp/PISLuqGaNbHgjiLkSeaBNARwn4KxUfXty/z8gn3e2DF 15 | Ntk23uZnehiTwKvRyRS84VezBroGhkOckmnbo8zOcH2SNG8/y8a5B6ZudTIJtTrT 16 | WV00rG9cL2ZwAMMalWdQBmDNBgbDYewdXERdn5QiHWZPxS0f9WXxQHKV9AyIdVJj 17 | pu06vx/wuy+V+1evZsiS4eHF4REcSMolrwaTk6V5GQKBgQDtOLEcdyAwx0rpQOD9 18 | ICkg87oZ1AP7/WUwRay/BGzGGFliMt6bbQ22dNNE4Sep2l31vz4NBVmtdvDsfwpn 19 | XlVzsImITfVTSkyyzhO1luXBCABzfR7GiaNQSGp7709+xrMstnKyZw1FNNHMra6e 20 | 05fGYPri6uKm0BvTL+xo3v1etwKBgQDBPqfL7oN/6HF9daBud8STlKFG5eyjv0m3 21 | Y5e/xVqhdPp5GoCz/pDNTtPhZQBs+3uLEsyDOn6FFOjni3iDwvoheZ34T+jKHpTV 22 | h8WOoJ9LOJhEStZ5u3DvhhgudP6U0SbsAuFy/6o+C8xP/CkDG4Ge2KpcC3pJH5uA 23 | 6/fpr/3COwKBgAN3tq8R1rif0SqDtkY8+BzxMyE5hi1i0N3ZxuKr7+MdbAEReUuQ 24 | Voj6QDRbjjbfaEw1VXTfRSZR/MeYO9CzAlDEnd4ONa3YAjMC7CrVX9pogYkupQqF 25 | 7Is548SYBPN3eBsJN7f/5aPDV+XEDC9qLGfL9x7mDBYgKKf3pV8LE20VAoGAZNQf 26 | Uy2xGUUcKjz8p4cAX4yWldqUHWBKw1BItnvv7PyPUC7+5mu1/BncPeeoUDTrYkY9 27 | xV748tFVMLM5/231ew/s18pCCWvpdnywHNo8I1B1SnTN8ZhWtfN+nIbY6qcyqsRa 28 | A9nYZyVaxoUolQF+IXaldP9cH9lJFvyITztPqU8CgYBPzR5gOVlYQ6VTcyca0IXU 29 | i5xQiXgJneBX+T7OHih2ma46XZ7FuPy8yd4iLACoxgjUVApqfH+Il9xCAPYS+DBe 30 | xGKzqoSZu3s2fj+AFvCVvgBhMMI50tYMsaYKyxiWF4VFzokhOek6G6yc12tD5qQ5 31 | bOL5p3T6XG2ZDz63umEQWA== 32 | -----END PRIVATE KEY----- 33 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/ssl-test.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ansible-collections/community.cassandra/4f25557c951f1e181236f289f6d9b9d9ad53218e/tests/integration/targets/cassandra_ssl/files/ssl-test.p12 -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/files/truststore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ansible-collections/community.cassandra/4f25557c951f1e181236f289f6d9b9d9ad53218e/tests/integration/targets/cassandra_ssl/files/truststore.jks -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | - setup_cassandra_cluster_manager 5 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - libpython-dev 4 | - python-requests 5 | - libev4 6 | - libev-dev 7 | - python-openssl 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - python-devel 4 | - python-requests 5 | - libev 6 | - libev-devel 7 | - pyOpenSSL 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_ssl/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_admin_user: cassandra 2 | cassandra_admin_pwd: cassandra 3 | cassandra_auth_tests: True 4 | cassandra_nodes: # Changes in 4.0 means we need to add nodes to certain DCs for some stuff to work 5 | - dc: "london" # 5 seeds because of this https://github.com/ibmcb/cbtool/issues/59 6 | node: "london1" 7 | ip: "127.0.0.1" 8 | port: 7100 9 | debug_port: 2000 10 | args: "--seeds" 11 | - dc: "london" 12 | node: "london2" 13 | ip: "127.0.0.2" 14 | port: 7200 15 | debug_port: 2001 16 | args: "--seeds" 17 | - dc: "paris" 18 | node: "paris1" 19 | ip: "127.0.0.3" 20 | port: 7300 21 | debug_port: 2002 22 | args: "--seeds" 23 | - dc: "new_york" 24 | node: "new_york1" 25 | ip: "127.0.0.4" 26 | port: 7400 27 | debug_port: 2003 28 | args: "--seeds" 29 | - dc: "tokyo" 30 | node: "tokyo1" 31 | ip: "127.0.0.5" 32 | port: 7500 33 | debug_port: 2004 34 | args: "--seeds" 35 | - dc: "zurich" 36 | node: "zurich1" 37 | ip: "127.0.0.6" 38 | port: 7600 39 | debug_port: 2005 40 | args: "--seeds" 41 | - dc: "amsterdam" 42 | node: "amsterdam1" 43 | ip: "127.0.0.7" 44 | port: 7700 45 | debug_port: 2006 46 | args: "--seeds" 47 | # - dc: "marlow" 48 | # node: "marlow1" 49 | # ip: "127.0.0.8" 50 | # port: 7800 51 | # debug_port: 2007 52 | # args: "" 53 | cassandra_service: cassandra -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_status/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | - setup_cassandra_cluster_manager 5 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_status/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_stopdaemon/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_stopdaemon/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_gossip module 2 | # (c) 2019, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Run stopdaemon on the node 22 | community.cassandra.cassandra_stopdaemon: 23 | debug: true 24 | register: stopdaemon 25 | 26 | - assert: 27 | that: 28 | - "stopdaemon.msg == 'nodetool stopdaemon executed successfully'" 29 | - "stopdaemon.changed == True" 30 | 31 | - name: Restart Cassandra 32 | service: 33 | name: cassandra 34 | state: restarted 35 | 36 | - name: Wait for Cassandra to become active 37 | wait_for: 38 | port: 9042 39 | host: 0.0.0.0 40 | delay: 10 41 | 42 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 43 | when: cassandra_auth_tests == True 44 | 45 | - name: Run stopdaemon with auth 46 | community.cassandra.cassandra_stopdaemon: 47 | username: "{{ cassandra_admin_user }}" 48 | password: "{{ cassandra_admin_pwd }}" 49 | debug: true 50 | register: stopdaemon 51 | 52 | - assert: 53 | that: 54 | - "stopdaemon.msg == 'nodetool stopdaemon executed successfully'" 55 | - "stopdaemon.changed == True" 56 | 57 | - name: Restart Cassandra 58 | service: 59 | name: cassandra 60 | state: restarted 61 | 62 | - name: Wait for Cassandra to become active 63 | wait_for: 64 | port: 9042 65 | host: 0.0.0.0 66 | delay: 10 67 | 68 | - name: Test login failure handling 69 | community.cassandra.cassandra_stopdaemon: 70 | username: "{{ cassandra_admin_user }}" 71 | password: XXXXXXXXXXXXXXXXXXXXX 72 | debug: true 73 | register: login_status 74 | ignore_errors: true 75 | when: cassandra_auth_tests == True 76 | 77 | - name: Assert failed login 78 | assert: 79 | that: 80 | - login_status.failed == True 81 | - "'Invalid username or password' in login_status.stderr" 82 | when: cassandra_auth_tests == True 83 | 84 | - name: Test incorrect nodetool_path handling 85 | community.cassandra.cassandra_stopdaemon: 86 | nodetool_path: /tmp 87 | debug: true 88 | register: nodetool_path_error 89 | ignore_errors: true 90 | when: cassandra_auth_tests == True 91 | 92 | - name: Assert no such file 93 | assert: 94 | that: 95 | - "'No such file or directory' in nodetool_path_error.msg" 96 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_stopdaemon/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_streamthroughput/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_streamthroughput/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_table/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_table/tasks/284.yml: -------------------------------------------------------------------------------- 1 | - name: Create a keyspace for tests 2 | cassandra_keyspace: 3 | name: consistency 4 | state: present 5 | login_user: "{{ cassandra_admin_user }}" 6 | login_password: "{{ cassandra_admin_pwd }}" 7 | 8 | - name: Create a test keyspace - LOCAL_ONE consistency 9 | community.cassandra.cassandra_table: 10 | name: local 11 | keyspace: consistency 12 | state: present 13 | columns: 14 | - id: uuid 15 | - username: text 16 | - encrypted_password: blob 17 | - first_name: text 18 | - last_name: text 19 | - dob: date 20 | primary_key: 21 | - username 22 | consistency_level: "LOCAL_ONE" 23 | login_user: "{{ cassandra_admin_user }}" 24 | login_password: "{{ cassandra_admin_pwd }}" 25 | register: local 26 | 27 | - assert: 28 | that: 29 | - local.changed 30 | 31 | - name: Create a test keyspace- ANY consistency 32 | community.cassandra.cassandra_table: 33 | name: any 34 | keyspace: consistency 35 | state: present 36 | columns: 37 | - id: uuid 38 | - username: text 39 | - encrypted_password: blob 40 | - first_name: text 41 | - last_name: text 42 | - dob: date 43 | primary_key: 44 | - username 45 | consistency_level: "ANY" 46 | login_user: "{{ cassandra_admin_user }}" 47 | login_password: "{{ cassandra_admin_pwd }}" 48 | register: any 49 | 50 | - assert: 51 | that: 52 | - any.changed 53 | 54 | - name: Create a test keyspace - QUORUM consistency 55 | community.cassandra.cassandra_table: 56 | name: quorum 57 | keyspace: consistency 58 | state: present 59 | columns: 60 | - id: uuid 61 | - username: text 62 | - encrypted_password: blob 63 | - first_name: text 64 | - last_name: text 65 | - dob: date 66 | primary_key: 67 | - username 68 | consistency_level: "QUORUM" 69 | login_user: "{{ cassandra_admin_user }}" 70 | login_password: "{{ cassandra_admin_pwd }}" 71 | register: quorum 72 | 73 | - assert: 74 | that: 75 | - quorum.changed 76 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_table/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - libpython-dev 4 | - python-requests 5 | - libev4 6 | - libev-dev 7 | - python-openssl 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_table/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | packages_for_cass_driver: 2 | - gcc 3 | - python-devel 4 | - python-requests 5 | - libev 6 | - libev-devel 7 | - pyOpenSSL 8 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_table/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_thrift/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_thrift/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_timeout/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_timeout/tasks/timeout_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: "Set {{ item }} timeout with module" 3 | community.cassandra.cassandra_timeout: 4 | username: "{{ cassandra_admin_user }}" 5 | password: "{{ cassandra_admin_pwd }}" 6 | timeout: 15999 7 | timeout_type: "{{ item }}" 8 | debug: true 9 | register: result 10 | 11 | - set_fact: 12 | mymsg: "{{ item }} timeout changed" 13 | 14 | - assert: 15 | that: 16 | - result.changed 17 | - result.msg == mymsg 18 | 19 | - name: "Get {{ item }} timeout" 20 | ansible.builtin.shell: nodetool -u {{ cassandra_admin_user }} -pw {{ cassandra_admin_pwd }} -h 127.0.0.1 gettimeout {{ item }} 21 | register: result 22 | 23 | - set_fact: 24 | mymsg: "Current timeout for type {{ item }}: 15999 ms" 25 | 26 | - name: Assert timeout is 15999 ms 27 | assert: 28 | that: mymsg == result.stdout 29 | 30 | - name: Set throughput to 15999 again 31 | community.cassandra.cassandra_timeout: 32 | username: "{{ cassandra_admin_user }}" 33 | password: "{{ cassandra_admin_pwd }}" 34 | timeout: 15999 35 | timeout_type: "{{ item }}" 36 | debug: true 37 | register: result 38 | 39 | - set_fact: 40 | mymsg: "{{ item }} timeout unchanged" 41 | 42 | - assert: 43 | that: 44 | - "result.changed == False" 45 | - result.msg == mymsg 46 | 47 | - name: Set timeout to 0 (check mode) 48 | community.cassandra.cassandra_timeout: 49 | username: "{{ cassandra_admin_user }}" 50 | password: "{{ cassandra_admin_pwd }}" 51 | timeout: 0 52 | timeout_type: "{{ item }}" 53 | debug: true 54 | check_mode: yes 55 | register: result 56 | 57 | - set_fact: 58 | mymsg: "{{ item }} timeout changed" 59 | 60 | - assert: 61 | that: 62 | - result.changed 63 | - result.msg == mymsg 64 | 65 | - name: Set timeout to 100 66 | community.cassandra.cassandra_timeout: 67 | username: "{{ cassandra_admin_user }}" 68 | password: "{{ cassandra_admin_pwd }}" 69 | timeout: 100 70 | timeout_type: "{{ item }}" 71 | debug: true 72 | register: result 73 | 74 | - set_fact: 75 | mymsg: "{{ item }} timeout changed" 76 | 77 | - assert: 78 | that: 79 | - result.changed 80 | - result.msg == mymsg 81 | 82 | - name: "Get {{ item }} timeout" 83 | ansible.builtin.shell: nodetool -u {{ cassandra_admin_user }} -pw {{ cassandra_admin_pwd }} -h 127.0.0.1 gettimeout {{ item }} 84 | register: result 85 | 86 | - set_fact: 87 | expected_stdout: "Current timeout for type {{ item }}: 100 ms" 88 | 89 | - name: Ensure timeout is 100 90 | assert: 91 | that: 92 | - result.stdout == expected_stdout 93 | 94 | - name: Return timeout to something high otherwise we mess up later tests 95 | community.cassandra.cassandra_timeout: 96 | username: "{{ cassandra_admin_user }}" 97 | password: "{{ cassandra_admin_pwd }}" 98 | timeout: 5000 99 | timeout_type: "{{ item }}" 100 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_timeout/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | cassandra_3_timeouts: 3 | - read 4 | - range 5 | - write 6 | - counterwrite 7 | - cascontention 8 | - truncate 9 | #- streamingsocket 10 | - misc 11 | cassandra_4_timeouts: 12 | - read 13 | - range 14 | - write 15 | - counterwrite 16 | - cascontention 17 | - truncate 18 | - internodeconnect 19 | - internodeuser 20 | - internodestreaminguser 21 | - misc -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_traceprobability/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_traceprobability/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_truncatehints/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_truncatehints/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_truncatehints module 2 | # (c) 2021, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: Truncate hints the node 22 | community.cassandra.cassandra_truncatehints: 23 | debug: true 24 | register: truncate 25 | 26 | - assert: 27 | that: 28 | - "truncate.msg == 'nodetool truncatehints executed successfully'" 29 | - "truncate.changed == True" 30 | 31 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 32 | when: cassandra_auth_tests == True 33 | 34 | - name: Truncate hints with auth 35 | community.cassandra.cassandra_truncatehints: 36 | username: "{{ cassandra_admin_user }}" 37 | password: "{{ cassandra_admin_pwd }}" 38 | debug: true 39 | register: truncate 40 | 41 | - assert: 42 | that: 43 | - "truncate.msg == 'nodetool truncatehints executed successfully'" 44 | - "truncate.changed == True" 45 | 46 | - name: Test login failure handling 47 | community.cassandra.cassandra_truncatehints: 48 | username: "{{ cassandra_admin_user }}" 49 | password: XXXXXXXXXXXXXXXXXXXXX 50 | debug: true 51 | register: login_status 52 | ignore_errors: yes 53 | when: cassandra_auth_tests == True 54 | 55 | - name: Assert failed login 56 | assert: 57 | that: 58 | - login_status.failed == True 59 | - "'Invalid username or password' in login_status.stderr" 60 | when: cassandra_auth_tests == True 61 | 62 | - name: Test incorrect nodetool_path handling 63 | community.cassandra.cassandra_truncatehints: 64 | nodetool_path: /tmp 65 | debug: true 66 | register: nodetool_path_error 67 | ignore_errors: true 68 | when: cassandra_auth_tests == True 69 | 70 | - name: Assert no such file 71 | assert: 72 | that: 73 | - "'No such file or directory' in nodetool_path_error.msg" 74 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_truncatehints/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_upgradesstables/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_upgradesstables/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # test code for the cassandra_gossip module 2 | # (c) 2019, Rhys Campbell 3 | 4 | # This file is part of Ansible 5 | # 6 | # Ansible is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Ansible is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with Ansible. If not, see . 18 | 19 | # =========================================================== 20 | 21 | - name: upgradesstablesUpgrade sstables on the node 22 | community.cassandra.cassandra_upgradesstables: 23 | debug: yes 24 | register: upgradesstables 25 | 26 | - assert: 27 | that: 28 | - "upgradesstables.msg == 'nodetool upgradesstables executed successfully'" 29 | - "upgradesstables.changed == True" 30 | 31 | - name: Restart Cassandra 32 | service: 33 | name: cassandra 34 | state: restarted 35 | 36 | - name: Wait for Cassandra to become active 37 | wait_for: 38 | port: 9042 39 | host: 0.0.0.0 40 | delay: 10 41 | 42 | - include_tasks: ../../setup_cassandra/tasks/cassandra_auth.yml 43 | when: cassandra_auth_tests == True 44 | 45 | - name: Run upgradesstables with auth 46 | community.cassandra.cassandra_upgradesstables: 47 | username: "{{ cassandra_admin_user }}" 48 | password: "{{ cassandra_admin_pwd }}" 49 | debug: yes 50 | register: upgradesstables 51 | 52 | - assert: 53 | that: 54 | - "upgradesstables.msg == 'nodetool upgradesstables executed successfully'" 55 | - "upgradesstables.changed == True" 56 | 57 | - name: Restart Cassandra 58 | service: 59 | name: cassandra 60 | state: restarted 61 | 62 | - name: Wait for Cassandra to become active 63 | wait_for: 64 | port: 9042 65 | host: 0.0.0.0 66 | delay: 10 67 | 68 | - name: Test login failure handling 69 | community.cassandra.cassandra_upgradesstables: 70 | username: "{{ cassandra_admin_user }}" 71 | password: XXXXXXXXXXXXXXXXXXXXX 72 | debug: yes 73 | register: login_status 74 | ignore_errors: yes 75 | when: cassandra_auth_tests == True 76 | 77 | - name: Assert failed login 78 | assert: 79 | that: 80 | - login_status.failed == True 81 | - "'Invalid username or password' in login_status.stderr" 82 | when: cassandra_auth_tests == True 83 | 84 | - name: Test incorrect nodetool_path handling 85 | community.cassandra.cassandra_upgradesstables: 86 | nodetool_path: /tmp 87 | debug: yes 88 | register: nodetool_path_error 89 | ignore_errors: true 90 | when: cassandra_auth_tests == True 91 | 92 | - name: Assert no such file 93 | assert: 94 | that: 95 | - "'No such file or directory' in nodetool_path_error.msg" 96 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_upgradesstables/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_verify/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - setup_cassandra 4 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_verify/tasks/4_1_verify_disabled.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: verify the node 3 | community.cassandra.cassandra_verify: 4 | debug: yes 5 | register: verify 6 | ignore_errors: true 7 | 8 | - assert: 9 | that: 10 | - "'verify is disabled unless a [-f|--force] override' in verify.stdout" 11 | - "verify.changed == False" -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_verify/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "Run old verify tests" 4 | import_tasks: old_verify.yml 5 | when: cassandra_version == "40x" or cassandra_version == "311x" 6 | 7 | - name: "Run tests for 4.1" 8 | import_tasks: 4_1_verify_disabled.yml 9 | when: cassandra_version == "41x" 10 | -------------------------------------------------------------------------------- /tests/integration/targets/cassandra_verify/vars/main.yml: -------------------------------------------------------------------------------- 1 | cassandra_auth_tests: True 2 | -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # The cassandra_version var should be set to one 2 | # of the dirs in https://downloads.apache.org/cassandra/redhat/ 3 | cassandra_version: "40x" 4 | openjdk: java-1.8.0-openjdk 5 | 6 | cassandra_yum: 7 | description: "Apache Cassandra" 8 | name: cassandra_yum 9 | baseurl: "https://www.apache.org/dist/cassandra/redhat/{{ cassandra_version }}/" 10 | enabled: yes 11 | gpgcheck: yes 12 | gpgkey: "https://www.apache.org/dist/cassandra/KEYS" 13 | 14 | cassandra_deb: 15 | repo: deb https://debian.cassandra.apache.org {{ cassandra_version }} main 16 | gpgkey: "https://www.apache.org/dist/cassandra/KEYS" 17 | 18 | cassandra_yum_pkg: cassandra 19 | cassandra_deb_pkg: cassandra 20 | cassandra_service: cassandra 21 | 22 | cassandra_yml_file: "/etc/cassandra/conf/cassandra.yaml" 23 | cassandra_env_file: "/etc/cassandra/conf/cassandra-env.sh" 24 | cassandra_regexp: '^authenticator*' 25 | cassandra_authenticator: "authenticator: PasswordAuthenticator" 26 | cassandra_regexp_auth: '^authorizer*' 27 | cassandra_authorizer: "authorizer: CassandraAuthorizer" 28 | 29 | cassandra_admin_user: cassandra 30 | cassandra_admin_pwd: cassandra 31 | 32 | # Generic Linux Packages 33 | required_packages: 34 | - "net-tools" 35 | 36 | redhat_packages: 37 | - "dnf" # switch to dnf to avoid rich dep error - https://wdoust.blogspot.com/2021/04/broken-ym-rich-dependencies.html -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/handlers/cleanup_debian_env.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Remove cassandra rpm 3 | apt: 4 | name: "{{ cassandra_deb_pkg }}" 5 | state: absent -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/handlers/cleanup_redhat7_env.yml: -------------------------------------------------------------------------------- 1 | - name: redhat_remove_cassandra 2 | yum: 3 | name: "{{ cassandra_yum_pkg }}" 4 | state: absent 5 | 6 | - name: Downgrade pip when CentOS 7 7 | pip: 8 | name: pip==8.1.2 9 | when: 10 | - ansible_os_family == 'RedHat' 11 | - ansible_distribution_major_version == "7" 12 | -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/handlers/main.yml: -------------------------------------------------------------------------------- 1 | - name: redhat_remove_cassandra 2 | include_tasks: cleanup_redhat7_env.yml 3 | 4 | # RPM Pulls down python2.7 5 | - name: debian_remove_cassandra 6 | include_tasks: cleanup_debian_env.yml 7 | -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/tasks/cassandra_deauth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # (c) 2020, Rhys Campbell 3 | 4 | # This file contains tasks to remove auth from a Cassandra instance 5 | 6 | # This file is part of Ansible 7 | # 8 | # Ansible is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # Ansible is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with Ansible. If not, see . 20 | 21 | # ============================================================ 22 | - name: Include vars for os family 23 | include_vars: 24 | file: "{{ ansible_os_family }}.yml" 25 | 26 | - name: Unset authenticator in cassandra.yml 27 | lineinfile: 28 | path: "{{ cassandra_yml_file }}" 29 | regexp: "{{ cassandra_regexp }}" 30 | line: "authenticator: AllowAllAuthenticator" 31 | 32 | - name: Unset authorizer in cassandra.yml 33 | lineinfile: 34 | path: "{{ cassandra_yml_file }}" 35 | regexp: "{{ cassandra_regexp_auth }}" 36 | line: "authorizer: AllowAllAuthorizer" 37 | 38 | - name: Remove lines for nodetool auth to cassandra-env.sh 39 | blockinfile: 40 | state: absent 41 | marker: "# {mark} ANSIBLE MANAGED BLOCK - nodetool auth" 42 | dest: "{{ cassandra_env_file }}" 43 | block: | 44 | JVM_OPTS="$JVM_OPTS -Djava.security.auth.login.config=$CASSANDRA_HOME/cassandra-jaas.config" 45 | JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.authorizer=org.apache.cassandra.auth.jmx.AuthorizationProxy" 46 | 47 | - name: Deactivate local jmx 48 | lineinfile: 49 | path: "{{ cassandra_env_file }}" 50 | regexp: '^if \[ \"\$LOCAL_JMX\" \=*' 51 | line: 'if [ "$LOCAL_JMX" = "yes" ]; then' 52 | 53 | - name: Remove jmx auth options 54 | blockinfile: 55 | state: absent 56 | marker: "# {mark} ANSIBLE MANAGED BLOCK - JMX Auth -->" 57 | path: "{{ cassandra_env_file }}" 58 | block: | 59 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true" 60 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password" 61 | JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=/etc/cassandra/jmxremote.access" 62 | 63 | - name: Restart cassandra 64 | service: 65 | name: "{{ cassandra_service }}" 66 | state: "restarted" 67 | register: cassandra_restarted 68 | 69 | - name: Wait for Cassandra to become active 70 | wait_for: 71 | port: 9042 72 | host: 0.0.0.0 73 | delay: 10 74 | when: cassandra_restarted.changed == True 75 | 76 | - pause: 77 | seconds: 10 78 | when: cassandra_restarted.changed == True 79 | 80 | - name: Test nodetool without auth from shell 81 | command: nodetool status 82 | 83 | - name: Test cqlsh access without auth 84 | command: cqlsh localhost --execute "DESC KEYSPACES" 85 | register: cqlsh_login 86 | -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | cassandra_env_file: "/etc/cassandra/cassandra-env.sh" 2 | cassandra_yml_file: "/etc/cassandra/cassandra.yaml" 3 | -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | cassandra_env_file: /etc/cassandra/default.conf/cassandra-env.sh 2 | -------------------------------------------------------------------------------- /tests/integration/targets/setup_cassandra_cluster_manager/defaults/main.yml: -------------------------------------------------------------------------------- 1 | openjdk: java-1.8.0-openjdk 2 | pip_packages: 3 | - pyYaml 4 | - six 5 | - psutil==5.7.0 6 | ant_version: "1.10.14" 7 | ant_download: "https://downloads.apache.org/ant/binaries/apache-ant-{{ ant_version }}-bin.tar.gz" 8 | cassandra_version: 4.0.11 # Released version from http://archive.apache.org/dist/cassandra/ 9 | cassandra_nodes: # Changes in 4.0 means we need to add nodes to certain DCs for some stuff to work 10 | - dc: "london" # 5 seeds because of this https://github.com/ibmcb/cbtool/issues/59 11 | node: "london1" 12 | ip: "127.0.0.1" 13 | port: 7100 14 | debug_port: 2000 15 | args: "--seeds" 16 | - dc: "london" 17 | node: "london2" 18 | ip: "127.0.0.2" 19 | port: 7200 20 | debug_port: 2001 21 | args: "--seeds" 22 | - dc: "paris" 23 | node: "paris1" 24 | ip: "127.0.0.3" 25 | port: 7300 26 | debug_port: 2002 27 | args: "--seeds" 28 | - dc: "new_york" 29 | node: "new_york1" 30 | ip: "127.0.0.4" 31 | port: 7400 32 | debug_port: 2003 33 | args: "--seeds" 34 | - dc: "tokyo" 35 | node: "tokyo1" 36 | ip: "127.0.0.5" 37 | port: 7500 38 | debug_port: 2004 39 | args: "--seeds" 40 | - dc: "zurich" 41 | node: "zurich1" 42 | ip: "127.0.0.6" 43 | port: 7600 44 | debug_port: 2005 45 | args: "--seeds" 46 | - dc: "amsterdam" 47 | node: "amsterdam1" 48 | ip: "127.0.0.7" 49 | port: 7700 50 | debug_port: 2006 51 | args: "--seeds" 52 | - dc: "marlow" 53 | node: "marlow1" 54 | ip: "127.0.0.8" 55 | port: 7800 56 | debug_port: 2007 57 | args: "" 58 | cassandra_service: cassandra # Service from setup_cassandra. We don't want this running for the cluster tests 59 | required_packages: "{{ ['zip', 'unzip', 'gcc', 'python3-dev', 'dpkg-dev'] if ansible_os_family == 'Debian' else ['zip', 'unzip', 'gcc', 'python3-devel'] if ansible_os_family == 'RedHat' else ['zip', 'unzip', 'gcc', 'python3-dev']}}" 60 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.15.txt: -------------------------------------------------------------------------------- 1 | ignore-2.19.txt -------------------------------------------------------------------------------- /tests/sanity/ignore-2.16.txt: -------------------------------------------------------------------------------- 1 | ignore-2.19.txt -------------------------------------------------------------------------------- /tests/sanity/ignore-2.17.txt: -------------------------------------------------------------------------------- 1 | ignore-2.19.txt -------------------------------------------------------------------------------- /tests/sanity/ignore-2.18.txt: -------------------------------------------------------------------------------- 1 | ignore-2.19.txt -------------------------------------------------------------------------------- /tests/sanity/ignore-2.19.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/cassandra_keyspace.py validate-modules:import-error 2 | plugins/modules/cassandra_role.py validate-modules:import-error 3 | plugins/modules/cassandra_table.py validate-modules:import-error 4 | plugins/modules/cassandra_keyspace.py import-3.9 5 | plugins/modules/cassandra_role.py import-3.9 6 | plugins/modules/cassandra_table.py import-3.9 --------------------------------------------------------------------------------