community.cassandra.cassandra_cqlsh (1.3.3) — module

Run cql commands via the clqsh shell.

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

Run cql commands via the clqsh shell.

Run commands inline or using a cql file.

Attempts to parse returned data into a format that Ansible can use.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run the DESC KEYSPACES cql command
  community.cassandra.cassandra_cqlsh:
    execute: "DESC KEYSPACES"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run a file containing cql commands
  community.cassandra.cassandra_cqlsh:
    file: "/path/to/cql/file.sql"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run a cql query returning json data
  community.cassandra.cassandra_cqlsh:
    execute: "SELECT json * FROM my_keyspace.my_table WHERE partition = 'key' LIMIT 10"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Use a different python
  community.cassandra.cassandra_cqlsh:
    execute: "SELECT json * FROM my_keyspace.my_table WHERE partition = 'key' LIMIT 10"
    additional_args:
      python: /usr/bin/python2

Inputs

    
ssl:
    default: false
    description:
    - Use SSL.
    type: bool

tty:
    default: false
    description:
    - Force tty mode.
    type: bool

file:
    description:
    - Path to a file containing cql commands.
    type: str

debug:
    default: false
    description:
    - show additional debug info.
    type: bool

cqlshrc:
    description:
    - Specify an alternative cqlshrc file location.
    type: str

execute:
    description:
    - cqlsh command to execute.
    type: str

encoding:
    default: utf-8
    description:
    - Specify a non-default encoding for output.
    type: str

keyspace:
    description:
    - Authenticate to the given keyspace.
    type: str

password:
    aliases:
    - login_password
    description:
    - The C* users password.
    type: str

username:
    aliases:
    - login_user
    description:
    - The C* user to authenticate with.
    type: str

cqlsh_cmd:
    default: cqlsh
    description:
    - cqlsh executable.
    type: str

transform:
    choices:
    - auto
    - split
    - json
    - raw
    default: auto
    description:
    - Transform the output returned to the user.
    - auto - Attempt to automatically decide the best tranformation.
    - split - Split output on a character.
    - json - parse as json.
    - raw - Return the raw output.
    type: str

cqlsh_host:
    aliases:
    - login_host
    default: localhost
    description:
    - Host to connect to
    type: str

cqlsh_port:
    aliases:
    - login_port
    default: 9042
    description:
    - Port to connect to.
    type: int

cqlversion:
    description:
    - Specify a particular CQL version.
    type: str

no_compact:
    default: false
    description:
    - No Compact.
    type: bool

split_char:
    default: ' '
    description:
    - Used by the split action in the transform stage.
    type: str

additional_args:
    description:
    - Additional arguments to supply to the mongo command.
    - Supply as key-value pairs.
    - If the parameter is a valueless flag supply a bool value.
    type: raw

connect_timeout:
    default: 5
    description:
    - Specify the connection timeout in seconds.
    type: int

request_timeout:
    default: 10
    description:
    - Specify the default request timeout in seconds.
    type: int

protocol_version:
    description:
    - Specify a specific protcol version.
    type: str

Outputs

changed:
  description: Change status.
  returned: always
  type: bool
err:
  description: Raw stderr from cqlsh.
  returned: when debug is set to true
  type: str
failed:
  description: Something went wrong.
  returned: on failure
  type: bool
file:
  description: CQL file that was executed successfully.
  returned: When a cql file is used.
  type: str
msg:
  description: A message indicating what has happened.
  returned: always
  type: str
out:
  description: Raw stdout from cqlsh.
  returned: when debug is set to true
  type: str
rc:
  description: Return code from cqlsh.
  returned: when debug is set to true
  type: int
transformed_output:
  description: Output from the cqlsh command. We attempt to parse this into a list
    or json where possible.
  returned: on success
  type: list