cassandra_keyspace -- Manage keyspaces on your Cassandra cluster.

Synopsis

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

The below requirements are needed on the host that executes this module.

Parameters

login_user (optional, str, None)
The Cassandra user to login with.
login_password (optional, str, None)
The Cassandra password to login with.
login_host (optional, list, None)

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.

login_port (optional, int, 9042)
The Cassandra poret.
name (True, str, None)
The name of the keyspace to create or manage.
state (True, str, None)
The desired state of the keyspace.
replication_factor (optional, int, 1)

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.

durable_writes (optional, bool, True)

Enable durable writes for the keyspace.

If not supplied the default value will be used.

data_centres (optional, dict, None)

The keyspace will be created with NetworkTopologyStrategy.

Specify your data centres, along with replication_factor, as key-value pairs.

Examples

- name: Create a keyspace
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    state: present

- name: Remove a keyspace
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    state: absent

- name: Create a keyspace with RF 3
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    state: present
    replication_factor: 3

- name: Create a keyspace with network topology
  community.cassandra.cassandra_keyspace:
    name: mykeyspace
    data_centres:
      london: 3
      paris: 3
      tokyo: 1
      new_york: 1

Return Values

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

Status

Authors

  • Rhys Campbell (@rhysmeister)