Command-line
Setup the CLI and run your first Task
Requirements
- Run this command to check if you have Nodejs installed. The result should be v11 or higher. If you don’t have Node installed or it’s in an old version, check this guide.
plain textnode -v
Setup
Install
plain textnpm install -g runops runops signup
Run a test command
plain textrunops targets list
Run your first Task
After setting up the CLI, it’s time to start using it. Runops Tasks
represent the scripts and commands you need to run against a live
resource (Connection).
Pick the Connection
The only thing you need to run a Task is a valid Connection. If your
company is using Runops, you already have a set of Connections
available. To see the Connections available you can use the list
Connections command in the CLI.
plain textrunops targets list
The result will look like this:
plain text┌──────────────────────────────┬──────────┬──────────┬──────────┬───────────────┬────────────────────┐ │ name │ type │ status │ review │ reviewers │ runner │ ├──────────────────────────────┼──────────┼──────────┼──────────┼───────────────┼────────────────────┤ │ db-prod-abc │ postgres │ active │ teams │ dba,sre │ runops-hosted │ └──────────────────────────────┴──────────┴──────────┴──────────┴───────────────┴────────────────────┘
This command will show a list of the Connections you can use to run
Tasks. Pick the one you need and take a note of the type, this will
define the type of scripts you will use in the Task. Also, check the review mode to understand the workflow of the
Connection.
Run the Task
Ok, now that we have a Connection, let’s create our Task. The
simplest possible way to create a Task is by providing the Connection
name and the script.
plain textrunops tasks create \ --target 'db-prod-abc' \ --message 'Creating my first Runops Task' --script 'select * from customers'
This Task has a SQL script, as the Connection type of Postgres based
on the Connections list command. The message is optional, but it’s a
good practice to add some context to what you are doing. This Connection
requires reviews and the message will help reviewers speed things
up.