::: {.index} pair: Working with the Digital Rebar CLI; Labs :::
2000 Working with the Digital Rebar CLI¶
Overview¶
- Id: 2000
- Time: 10 Minutes
- Enabled: Yes
- Difficulty: intermediate
- Tags: fundamentals
* Concepts: cli, machines, events, alerts, catalog .. youtube:: rpM0b8nqdVc :privacy_mode: Video Link
Objective¶
Learn how to use Digital Rebar by the command line for programmatic control
Using the Digital Rebar CLI, this lab will explore the ability to get and control DRP programmatically.
Business ROI: Improved automation skills results in improved IaC contruction and integration.
Prerequisites¶
Required Labs:
- 1200
Explore drpcli
¶
Setup CLI Environment¶
This step will provide you a terminal to window / shell to do
drpcli
commands.
::: {.tabs} ::: {.tab} DRP Shell
- Navigate to the Machines view
- Open the editor for the DRP endpoint machine
-
Click the
Remote
button in the upper right of new panelThe
Remote
button opens an SSH session from within the Portal. -
Resize the window for comfort
-
Set the endpoint and access credentials
During Lab 1000, Install Digital Rebar, you may have changed the access username and password. You will need to use those now to set an environment variable for accessing DRP. Since you are on the DRP Endpoint, the endpoint default value is sufficient.
If you used the Terraform Setup, then these values will be provided
For example:
:::
::: {.tab} Linux
- Open the files view
- Click
drpcli.<arch>.linux
where arch is amd64, arm64, or ppc64le to download - Click the download button
- Open a terminal in your home directory
-
Put the binary in place and make executable
-
Set the endpoint and access credentials
During the lab1000, you may have changed the access username and password. You will need to use those now to set an environment variable for accessing DRP.
If you used the Terraform Setup, then these values will be provided
For example:
:::
::: {.tab} Darwin
- Open the files view
- Click
drpcli.<arch>.darwin
where arch is amd64 or arm64 to download - Click the download button
- Open a terminal in your home directory
-
Put the binary in place and make executable
-
Set the endpoint and access credentials
During the lab1000, you may have changed the access username and password. You will need to use those now to set an environment variable for accessing DRP.
If you used the Terraform Setup, then these values will be provided
For example:
:::
::: {.tab} Windows
- Open the files view
- Click
drpcli.amd64.windows
to download - Open a powershell terminal
-
Put the binary in place and make executable
-
Set the endpoint and access credentials
During the lab1000, you may have changed the access username and password. You will need to use those now to set an environment variable for accessing DRP.
If you used the Terraform Setup, then these values will be provided
For example:
::: :::
Check Versions¶
Check
drpcli
versionThis should display something like:
Check
jq
versionThis should display something like:
Redo the previous
Setup CLI Environment
step if those commands fail
Test Access¶
Make sure that the environment is configured correctly
This should display something like:
v4.10.0
Redo the previous
Setup CLI Environment
if this commands fail
Experiment with Alerts¶
Create an alert
Navigate to Alerts
See the newly created alert in the table
The table will live update as other things change.
List the alerts from the CLI
Acknowledge the Alert from the CLI
Note the two
drpcli
calls. The innerdrpcli
call is used to get the Uuid of the most recent alert. The outerdrpcli
call is used to acknowledge it.
Playing with Machines with the CLI¶
Create a machine from the CLI
Look at the machine in the Portal
The machine view will update as the CLI makes changes.
Show the machine in the CLI
This will show the JSON object for that machine.
Set a workflow on the machine
This will show the JSON object for that machine.
Create a context container for the machine
This will show the JSON object for that machine.
Notice the machine run the universal-start workflow
Count the machines in the system
This will show the number machines in the system. Something like:
2
.Use the CLI to wait for changes in the object
This command will wait until the machine's description changes.
Go to the machine, change the Description, and click in the white space around the description.
The command returns
complete
.Remove the machine
This returns that the machine is deleted. Notice the machine is removed from the Portal.
Count the machines in the system (again)
This will show the number machines in the system. Something like:
2
The value is one less than before.
Watch for Events from the CLI¶
Install the dev-library content pack
A JSON object of the
dev-library
content pack will be returned.Subscribe for events
This command will run until stopped.
Navigate to Catalog
- Select
dev-library
row and clickDelete
Watch for the update events.
In the shell, the previously running command will show a JSON event indicating that the content pack was deleted.
Stop the event watcher in the shell by pressing cntrl-C