cassandra_table -- Create or drop tables on a Cassandra Keyspace.

Synopsis

Create or drop tables on a Cassandra Keyspace.

No alter functionality. If a table with the same name already exists then no changes are made.

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.
login_port (optional, int, 9042)
The Cassandra poret.
name (True, str, None)
The name of the table to create or drop.
state (True, str, None)
The desired state of the table.
keyspace (True, str, None)
The keyspace in which to create the table.
columns (optional, list, None)

The columns for the table.

Specifiy pairs as <column name>: <data type>

primary_key (optional, list, None)
The Primary key speicfication for the table
partition_key (False, list, [])
The partition key columns.
clustering (optional, list, None)
The clustering specification.
table_options (optional, dict, None)
Options for the table
is_type (optional, bool, False)
Create a type instead of a table
debug (optional, bool, False)
Debug flag

Examples

- name: Create a table
  community.cassandra.cassandra_table:
    name: users
    state: present
    keyspace: myapp
    columns:
      id: UUID
      username: text
      encrypted_password: blob
      email: text
      dob: date
      first_name: text
      last_name: text
      points: int
    primary_key:
      username

- name: Remove a table
  community.cassandra.cassandra_table:
    name: users
    state: absent
    keyspace: myapp

# killrvideo examples
- name: Create user_credentials table
  community.cassandra.cassandra_table:
    name: user_credentials
    state: present
    keyspace: killrvideo
    columns:
      - email: text
      - password: text
      - userid: uuid
    primary_key:
      - email
    login_user: admin
    login_password: secret
  register: user_credentials

- name: Create user table
  community.cassandra.cassandra_table:
    name: users
    state: present
    keyspace: killrvideo
    columns:
      - userid: uuid
      - firstname: varchar
      - lastname: varchar
      - email: text
      - created_date: timestamp
    primary_key:
      - userid
    login_user: admin
    login_password: secret
  register: users

- name: Create video_metadata type
  community.cassandra.cassandra_table:
    name: video_metadata
    state: present
    keyspace: killrvideo
    columns:
      - height: int
      - width: int
      - video_bit_rate: "set<text>"
      - encoding: text
    is_type: True
    login_user: admin
    login_password: secret
  register: video_metadata

- name: Create videos table
  community.cassandra.cassandra_table:
    name: videos
    state: present
    keyspace: killrvideo
    columns:
      - videoid: uuid
      - userid: uuid
      - name: varchar
      - description: varchar
      - location: text
      - location_type: int
      - preview_thumbnails: "map<text,text>"
      - tags: "set<varchar>"
      - metadata: "set<frozen<video_metadata>>"
      - added_date: "timestamp"
    primary_key:
      - videoid
    login_user: admin
    login_password: secret
  register: videos

- name: Create user_videos table
  community.cassandra.cassandra_table:
    name: user_videos
    state: present
    keyspace: killrvideo
    columns:
      - userid: uuid
      - added_date: timestamp
      - videoid: uuid
      - name: text
      - preview_image_location: text
    primary_key:
      - userid
      - added_date
      - videoid
    clustering:
      - added_date: "DESC"
      - videoid: "ASC"
    login_user: admin
    login_password: secret
  register: user_videos

- name: Create latest_videos table
  community.cassandra.cassandra_table:
    name: latest_videos
    state: present
    keyspace: killrvideo
    columns:
      - yyyymmdd: text
      - added_date: timestamp
      - videoid: uuid
      - name: text
      - preview_image_location: text
    primary_key:
      - yyyymmdd
      - added_date
      - videoid
    clustering:
      - added_date: "DESC"
      - videoid: "ASC"
    login_user: admin
    login_password: secret
  register: latest_videos

Return Values

changed (on success, bool, )
Whether the module has created or dropped
cql (changed, str, DROP TABLE users)
The cql used to create or drop the table
msg (on error, str, )
Exceptions encountered during module execution.

Status

Authors

  • Rhys Campbell (@rhysmeister)