Hi @future-accountant-19088,
This is totally doable. I haven't got a code example I can share unfortunately , but I do this on my clusters.
Firstly, if you're using harvester, rather than generic clusters you can use the harvester node driver in Rancher to provision your clusters, then it's all taken care of for you.
If you still want to do it yourself, assuming you provision the Rancher cluster with terraform too, the principle is...
1. Check your terraform state file for the cluster resource once created. In that JSON object somewhere will be registration command that you see in the UI.
2. If you're using local state you can set a terraform output from your cluster resource with the registration command. Or if you have temote state you can call a data resource in your VM provisioning terraform code for that registration command.
3. You then just add the variable assigned to the registration command as a provisioning step in your VM provisioning code.
Hope that helps, sorry I can't show you a code example.