Configure provisioning with viam-agent
The provisioning subsystem is a feature of viam-agent
, which you can install as part of your manufacturing process. agent-provisioning
will then perform the rest of the first-time setup for your machine once an end user sets up the machine.
This is useful when deploying a fleet of machines directly from the factory to a customer, or when bundling proprietary software on your Viam machine.
This guide will show you how to install and configure viam-agent
.
Prerequisites
Decide on the provisioning method
You can choose to let your end users complete machine setup by using a captive web portal or a mobile app.
If you choose to have a mobile app experience, you can use the Viam mobile app or create your own custom mobile app using the Flutter SDK or the TypeScript SDK to connect to viam-agent
and provision your machines.
If you choose to use the Viam mobile app, you must provide a fragment for provisioning. If you do not yet have a fragment, follow the steps to Create a configuration fragment and make a note of the fragment ID.
If you choose to use the captive web portal, you can optionally create a machine in advance and provide its machine cloud credentials file at
You can get the machine cloud credentials by clicking the copy icon next to Machine cloud credentials in the part status dropdown to the right of your machine’s name on the top of the page.
Configure agent-provisioning
Configure provisioning
If you are using the captive portal, this step is optional.
If you are using a mobile app, you must create a provisioning configuration file, specifying at least a fragment_id
.
Create a file called
{
"manufacturer": "<NAME>", # your company name
"model": "<NAME>", # the machine's model
"fragment_id": "<ID>", # the fragment id, required for mobile app
"hotspot_prefix": "<PREFIX>", # machine creates a hotspot during setup
"disable_dns_redirect": true, # disable if using a mobile app
"hotspot_password": "<PASSWORD>", # password for the hotspot
}
Install viam-agent
viam-agent
is a self-updating service manager that maintains the lifecycle for several Viam services and keeps them updated.
If you intend to use viam-agent
to keep your device’s Viam software up-to-date or to use its provisioning plugin to let end users set up their own machines, you need to use viam-agent
and install it on the machine before sending it to the user.
You can install viam-agent
on live systems or preinstall it:
Viam provides a preinstall script that works with images to add viam-agent
.
Support notice
Please note this script works only under POSIX (MacOS and Linux) at the moment.
1. Download the preinstall script
Run the following commands to download the preinstall script and make the script executable:
wget https://storage.googleapis.com/packages.viam.com/apps/viam-agent/preinstall.sh
chmod 755 preinstall.sh
2. Run the preinstall script
Run the preinstall script without options and it will attempt to auto-detect a mounted root filesystem (or for Raspberry Pi, bootfs) and also automatically determine the architecture.
sudo ./preinstall.sh
Follow the instructions.
If you created a
1. Create and download files
Run the following commands to create directories for the provisioning binaries, then download the binaries and make them executable:
mkdir -p /opt/viam/bin/ /opt/viam/tmp/
curl -fsSL https://storage.googleapis.com/packages.viam.com/apps/viam-agent/viam-agent-stable-x86_64 -o /opt/viam/bin/viam-agent-stable-x86_64
curl -fsSL https://storage.googleapis.com/packages.viam.com/apps/viam-agent-provisioning/viam-agent-provisioning-stable-x86_64 -o /opt/viam/bin/viam-agent-provisioning-stable-x86_64
chmod 755 /opt/viam/tmp/viam-agent*
mkdir -p /opt/viam/bin/ /opt/viam/tmp/
curl -fsSL https://storage.googleapis.com/packages.viam.com/apps/viam-agent/viam-agent-stable-aarch64 -o /opt/viam/bin/viam-agent-stable-aarch64
curl -fsSL https://storage.googleapis.com/packages.viam.com/apps/viam-agent-provisioning/viam-agent-provisioning-stable-aarch64 -o /opt/viam/bin/viam-agent-provisioning-stable-aarch64
chmod 755 /opt/viam/tmp/viam-agent*
2. Symlink the binaries
Symlink the agent binary to bin/viam-agent
and the provisioning binary to bin/agent-provisioning
:
ln -s /opt/viam/bin/viam-agent-stable-x86_64 bin/viam-agent
ln -s /opt/viam/bin/viam-agent-provisioning-stable-x86_64 bin/agent-provisioning
ln -s /opt/viam/bin/viam-agent-stable-aarch64 bin/viam-agent
ln -s /opt/viam/bin/viam-agent-provisioning-stable-aarch64 bin/agent-provisioning
Note
Use relative symlinks, especially if working on a mounted image (that is not a booted system).
3. Create the systemd service file
Copy the systemd service file from the agent repo to /etc/systemd/system/viam-agent.service
.
Then, symlink the service file to
curl -fsSL https://github.com/viamrobotics/agent/raw/main/subsystems/viamagent/viam-agent.service -o /etc/systemd/system/viam-agent.service
ln -s /etc/systemd/system/viam-agent.service /etc/systemd/system/multi-user.target.wants/viam-agent.service
Note
Use relative symlinks, especially if working on a mounted image (that is not a booted system).
4. Ensure NetworkManager is installed
Make sure NetworkManager version 1.42 or newer is installed and enabled in systemd
.
If you create a provisioning file, the file must be at
Troubleshooting
If you need to test the GRPC components of the provisioning service, there is a CLI client available.
Get the code from the agent-provisioning
repo and run go run ./cmd/client/
for info.
Next Steps
With provisioning configured, you can now direct the end user to follow the setup steps:
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!