Add a host automatically - /v2/script authentication string


#1

I’m trying to find a way of automatically adding a host to a Rancher 1.6.26 Server, and I’m not sure how I can find the url string that appears after /v2/scripts when I add a host in the interface. So basically I’m trying to do it within a vagrant environment for testing purposes.

Any advice on how I can get hold of the string automatically without having to manually copying it from the GUI?


#2

/v2-beta/projects/<project-id>/registrationTokens . The UI requests the creation of the first one so if there isn’t already one, send a POST to there first.


#3

I’m not sure if I understood the whole procedure correctly. So I’m trying this on a newly installed rancher server from what should become one of the hosts:

curl -X POST http://192.168.99.15:8080/v2-beta/projects/default/registrationTokens
{“id”:“4e314cf4-aae0-47db-b14f-55f1a2463286”,“type”:“error”,“links”:{},“actions”:{},“status”:403,“code”:“Forbidden”,“message”:“Forbidden”,“detail”:null,“baseType”:“error”}


#4

Project IDs are not the same as the name of the project. They are of the form 1a<number>. On a new installation, the “Default” project is always 1a5.