community.cassandra.cassandra_keyspace (1.3.3) — module

Manage keyspaces on your Cassandra cluster.

Authors: Rhys Campbell (@rhysmeister)

Install collection

Install with ansible-galaxy collection install community.cassandra:==1.3.3


Add to requirements.yml

  collections:
    - name: community.cassandra
      version: 1.3.3

Description

Manage keyspaces on your Cassandra Cluster.

Keyspace can be created to use SimpleStrategy or NetworkTopologyStrategy.

Keyspace modifications are supported, for example durable writes, replication factor or data centre changes but it is not supported to migrate between replication strategies i.e. NetworkTopologyStrategy -> SimpleStrategy.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a keyspace
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a keyspace
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a keyspace with RF 3
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    state: present
    replication_factor: 3
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a keyspace with network topology
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    data_centres:
      london: 3
      paris: 3
      tokyo: 1
      new_york: 1

Inputs

    
ssl:
    default: false
    description: Uses SSL encryption if basic SSL encryption is enabled on Cassandra cluster
      (without client/server verification)
    type: bool

name:
    description: The name of the keyspace to create or manage.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    description: The desired state of the keyspace.
    required: true
    type: str

login_host:
    description:
    - The Cassandra hostname.
    - If unset the instance will check 127.0.0.1 for a C* instance.
    - Otherwise the value returned by socket.getfqdn() is used.
    elements: str
    type: list

login_port:
    default: 9042
    description: The Cassandra poret.
    type: int

login_user:
    description: The Cassandra user to login with.
    type: str

data_centres:
    aliases:
    - data_centers
    description:
    - The keyspace will be created with NetworkTopologyStrategy.
    - Specify your data centres, along with replication_factor, as key-value pairs.
    type: dict

ssl_ca_certs:
    default: ''
    description: The SSL CA chain or certificate location to confirm supplied certificate
      validity (required when ssl_cert_reqs is set to CERT_OPTIONAL or CERT_REQUIRED)
    type: str

ssl_cert_reqs:
    choices:
    - CERT_NONE
    - CERT_OPTIONAL
    - CERT_REQUIRED
    default: CERT_NONE
    description: SSL verification mode.
    type: str

durable_writes:
    default: true
    description:
    - Enable durable writes for the keyspace.
    - If not supplied the default value will be used.
    type: bool

login_password:
    description: The Cassandra password to login with.
    type: str

replication_factor:
    default: 1
    description:
    - The total number of copies of your keyspace data.
    - The keyspace is created with SimpleStrategy.
    - If data_centres is set this parameter is ignored.
    - If not supplied the default value will be used.
    type: int

Outputs

changed:
  description: Whether the module has changed the keyspace.
  returned: on success
  type: bool
cql:
  description: The cql used to change the keyspace.
  returned: changed
  sample: 'ALTER KEYSPACE multidc_keyspace WITH REPLICATION = { ''class'' :/ ''NetworkTopologyStrategy'',
    ''new_york'' : 2,''tokyo'' : 1,''zurich'' : 3 } / AND DURABLE_WRITES = True'
  type: str
keyspace:
  description: The keyspace operated on.
  returned: on success
  type: str
msg:
  description: Exceptions encountered during module execution.
  returned: on error
  type: str