|  | 
|  | 1 | +# Unmanaged Nodes | 
|  | 2 | +The default mode of OneFuzz is to run the agents inside scalesets managed by the the Onefuzz instance. But it is possible to run outside of the Instance infrastructure. | 
|  | 3 | +This is the unmanaged scenario. In this mode, the user can use their own resource to participate in the fuzzing. | 
|  | 4 | + | 
|  | 5 | +## Set-up | 
|  | 6 | +These are the steps to run an unmanaged node | 
|  | 7 | + | 
|  | 8 | + | 
|  | 9 | +### Create an Application Registration in Azure Active Directory | 
|  | 10 | +We will create the authentication method for the unmanaged node. | 
|  | 11 | +From the [azure cli](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) create a new **application registration**: | 
|  | 12 | +```cmd | 
|  | 13 | +az ad app create --display-name <registration_name> | 
|  | 14 | +``` | 
|  | 15 | +Then use the application `app_id` in the result to create the associated **service principal**: | 
|  | 16 | + | 
|  | 17 | +```cmd | 
|  | 18 | +az ad sp create --id <app_id> | 
|  | 19 | +``` | 
|  | 20 | +Take note of the `id` returned by this request. We will call it the `principal_id`. | 
|  | 21 | + | 
|  | 22 | +Next, create a `client_secret`: | 
|  | 23 | + | 
|  | 24 | +``` | 
|  | 25 | +az ad app credential reset --id <pp_id> --append | 
|  | 26 | +``` | 
|  | 27 | +Take note of the `password` returned. | 
|  | 28 | + | 
|  | 29 | +### Authorize the application in OneFuzz | 
|  | 30 | +From the OneFuzz `deployment` folder run the following script using the `app_id` from above: | 
|  | 31 | +``` cmd | 
|  | 32 | +python .\deploylib\registration.py register_app <onefuzz_instance_id> <subscription_id> --app_id <app_id> --role UnmanagedNode | 
|  | 33 | +``` | 
|  | 34 | + | 
|  | 35 | +### Create an unmanaged pool | 
|  | 36 | +Using the OneFuzz CLI: | 
|  | 37 | +``` cmd | 
|  | 38 | +onefuzz pools create <pool_name> <os> --unmanaged --object_id <principal_id> | 
|  | 39 | +``` | 
|  | 40 | + | 
|  | 41 | +### Download the agent binaries and the agent configuration | 
|  | 42 | +Download a zip file containing the agent binaries: | 
|  | 43 | +``` | 
|  | 44 | +onefuzz tools get <destination_folder> | 
|  | 45 | +``` | 
|  | 46 | +Extract the zip file in a folder of your choice. | 
|  | 47 | + | 
|  | 48 | +Download the configuration file for the agent: | 
|  | 49 | + | 
|  | 50 | +``` | 
|  | 51 | +onefuzz pools get_config <pool_name> | 
|  | 52 | +``` | 
|  | 53 | + | 
|  | 54 | +Under the `client_credential` section of the agent config file, update `client_id` and `client_secret`: | 
|  | 55 | +```json | 
|  | 56 | +{ | 
|  | 57 | +    "client_id": "<app_id>", | 
|  | 58 | +    "client_secret": "<password>", | 
|  | 59 | +} | 
|  | 60 | +``` | 
|  | 61 | +Save the config to the file. | 
|  | 62 | + | 
|  | 63 | +### Start the agent. | 
|  | 64 | +Navigate to the folder corresponding to your OS. | 
|  | 65 | +Set the necessary environment variable by running the script `set-env.ps1` (for Windows) or `set-env.sh` (for Linux). | 
|  | 66 | +Run the agent with the following command. If you need more nodes use a different `machine_guid` for each one: | 
|  | 67 | +```cmd | 
|  | 68 | +onefuzz-agent run --machine_id <machine_guid> -c <path_to_config_file> --reset_lock | 
|  | 69 | +``` | 
|  | 70 | + | 
|  | 71 | +### Verify that the agent is registered to OneFuzz | 
|  | 72 | + | 
|  | 73 | +Using the OneFuzz CLI run the following command: | 
|  | 74 | + | 
|  | 75 | +``` | 
|  | 76 | +onefuzz nodes get <machine_guid> | 
|  | 77 | +``` | 
|  | 78 | + | 
|  | 79 | +This should return one entry. Verify that the `pool_name` matched the pool name created earlier. | 
|  | 80 | +From here you will be able to schedule jobs on that pool and they will be running. | 
0 commit comments