18. Digital Rebar Provision Command Line Interface (CLI)¶
The Digital Rebar Provision Command Line Interface (drpcli) provides a simplified way to interact with the Digital Rebar Provision API. The command line tool (
drpcli) is auto-generated from source code via reference of the API. This means the CLI should implement 100% coverage of the API.
The CLI provides help for commands and follows a pattern of chained parameters with a few flags for additional modifications.
Some examples are:
drpcli bootenvs list drpcli subnets get mysubnet drpcli preferences set defaultBootEnv discovery
The drpcli has help at each layer of command and is the easiest way to figure out what can and can not be done.
drpcli help drpcli bootenvs help
Each object in the Data Architecture has a CLI subcommand.
VERY IMPORTANT - the update commands use the PATCH operation for the objects in the Digital Rebar Provision API. This has the implication that for map like components (Params sections of Machine and Profile) the contents are merged with the existing object. For the Params sections specifically, use the subaction params to replace contents.
By default, the CLI will attempt to access the dr-provision API endpoint on the localhost at port 8092 with the username and password of rocketskates and r0cketsk8ts, respectively. All three of these values can be provided by environment variable or command line flag.
|Username||RS_KEY||-P or –password||String, but when part of RS_KEY it is: username:password|
|Password||RS_KEY||-U or –username||String, but when part of RS_KEY it is: username:password|
|Token||RS_TOKEN||N/A||Base64 encoded string from a generate token API call.|
|Endpoint||RS_ENDPOINT||-E or –endpoint||URL for access, https://IP:PORT. e.g. https://127.0.0.1:8092|
It is necessary to specify either a username and password or a token.
Another useful flag is –format. this will change the tool output to YAML instead of JSON. This can be helpful when editing files by hand. e.g. –format yaml
For Bash users, the drpcli can generate its own bash completion file. Once generated, it is necessary to restart the terminal/shell or reload the completions.
sudo drpcli autocomplete /etc/bash_completion.d/drpcli . /etc/bash_completion
Assuming that Brew is in use to update and manage bash and bash autocompletion.
sudo drpcli autocomplete /usr/local/etc/bash_completion.d/drpcli . /usr/local/etc/bash_completion