Cassandra CLI
Execute queries to a cassandra cluster with cqlsh.
Type: bash
Configuration
Name | Required | Description |
---|---|---|
CQLSH_KEYSPACE | yes | The keyspace target |
CQLSH_HOST | yes | The host of the Cassandra cluster |
CQLSH_PORT | no | The Vault Token. Defaults to 9043 |
CQLSH_USER | no | The user to connect in the Cassandra cluster. |
CQLSH_PASSWD | no | The password to connect in the Cassandra cluster. |
In order to configure this type, it's necessary to create the target directly from the API
runops login
CONNECTION_NAME=cqlsh-test
TAGS=test-agent
# for updating it, just change the from POST to PUT
curl -XPOST https://api.runops.io/v1/targets \
-H "Authorization: $(cat ~/.runops/config)" \
-H 'content-type: application/json' -d@- <<EOF
{
"tags": "$TAGS",
"secret_provider": "env-var",
"secret_path": "CQLSH_ENV",
"name": "$CONNECTION_NAME",
"type": "bash",
"custom_command": "cqlsh --no-color -u [[CQLSH_USER]] --password=[[CQLSH_PASSWD]] -k [[CQLSH_KEYSPACE]]"
}
EOF
tip
In this example, the agent needs to be configured with the environment variable CQLSH_ENV
as a json, example:
CQLSH_ENV='{"CQLSH_HOST":"127.0.0.1","CQLSH_USER":"foo","CQLSH_PASSWD":"noop","CQLSH_KEYSPACE":"test"}'
To add more options to the command line, update the custom command.
Examples
Then it's possible to run queries into a Cassandra connection
runops tasks create --target cqlsh-test --script 'SELECT * FROM table1;'