CLI
The Deviceplane CLI can be used to manage your project, devices, and to SSH into devices.
The Deviceplane CLI enables you to perform most actions available in the UI. With the CLI, you can quickly deploy, troubleshoot, and dig into issues via your terminal. It also offers output in JSON and YAML, so you can use it to write scripted workflows.
Usage
The CLI can be used to manage the following:
- Projects:
- List projects
- Create a new project
- Devices:
- List devices
- SSH into a device
- Inspect a device's properties and labels
- Reboot a device
Installation
To download the CLI, log in to Deviceplane, and click your user icon on the top right of the screen. You should see a dropdown that has "Download CLI" as one of the listed options. Click it, and select your OS.
Then, move the CLI to a folder in your $PATH
,
such as /usr/local/bin
. This will let
you run the deviceplane
command
anywhere, without needing the absolute file path. Afterwards, if you're on a
UNIX-based system chmod +x [path to
deviceplane]
, which will allow you to run the deviceplane
command.
Now, you should be able to run deviceplane
,
and see the help output.
Access keys
When using the CLI, an access key must be provided. Without this access key, Deviceplane will not be able to authenticate the request. Each user or service account can create access keys to use for the CLI. User access keys are scoped to a specific user and will have the same role as a user. Service account access keys are great to use when a service is being set up to make changes into Deviceplane. For example, it's best to use a service account access key instead of a user access key for CI/CD systems.
An access key and project name can be set
with the deviceplane configure
command,
or by using the DEVICEPLANE_ACCESS_KEY
and DEVICEPLANE_PROJECT
environment
variables, or the --access-key
and --project
flags. It's recommended
to use deviceplane configure
on your
developer machine, and use the environment variables on CI systems.
SSHing into devices
To SSH into a device, simply run deviceplane
ssh $DEVICE_NAME
. For more information, look at the SSH
docs, or look at command
scripting docs to see examples of using this in custom scripts.
Listing and inspecting resources
Listing resources can also be done in the
CLI using deviceplane $RESOURCE_TYPE
list
. Here, we list all devices in our project:
In the case of devices specifically, filters
can also be applied with the --filter
flag (more info with deviceplane device list
help
):
Resources can also be inspected, to show
their inner config, using deviceplane
$RESOURCE_TYPE inspect $RESOURCE_INSTANCE
. Here we inspect a single device:
Output formatting
Note that for command
scripting and other use cases, the output of the CLI can be configured using the
-o
or --output
flag.
For listing resource instances, the CLI
supports table
(the human-readable
default), yaml
, json
,
and json-stream
output. Here, we use
json-stream
output on our device list:
For inspecting individual resources, the CLI
supports yaml
and json
output. Here, we use json-stream
output
on our device list:
Autocompletion
To get CLI autocompletion, add eval
"$(deviceplane --completion-script-bash)"
to your bashrc file. If you're
using zsh, add eval "$(deviceplane
--completion-script-zsh)"
to your zshrc.
This allows you to autocomplete commands, as well as application, service, and device names, by pressing the tab key.