community / community.cassandra / 1.3.3 / module / cassandra_table Create or drop tables on a Cassandra Keyspace. Authors: Rhys Campbell (@rhysmeister)community.cassandra.cassandra_table (1.3.3) — module
Install with ansible-galaxy collection install community.cassandra:==1.3.3
collections: - name: community.cassandra version: 1.3.3
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.
- 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
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 table to create or drop. required: true type: str debug: default: false description: - Debug flag type: bool state: choices: - present - absent description: The desired state of the table. required: true type: str columns: description: - The columns for the table. - 'Specifiy pairs as <column name>: <data type>' elements: dict type: list is_type: default: false description: - Create a type instead of a table type: bool keyspace: description: - The keyspace in which to create the table. required: true type: str clustering: description: - The clustering specification. elements: dict type: list login_host: description: The Cassandra hostname. 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 primary_key: description: - The Primary key speicfication for the table elements: str type: list 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 partition_key: default: [] description: - The partition key columns. elements: str required: false type: list ssl_cert_reqs: choices: - CERT_NONE - CERT_OPTIONAL - CERT_REQUIRED default: CERT_NONE description: SSL verification mode. type: str table_options: description: - Options for the table type: dict login_password: description: The Cassandra password to login with. type: str
changed: description: Whether the module has created or dropped returned: on success type: bool cql: description: The cql used to create or drop the table returned: changed sample: DROP TABLE users type: str msg: description: Exceptions encountered during module execution. returned: on error type: str