Automating Server/Agent deployment


I am attempting (just using bash at the moment) to automate the deployment of a server and x agents in Openstack.
This seems to work to a point (just working out the pattern/workflow)

I can provision a server, (using cloud-init) and startup a RancherOS + Rancher Server, this works fine.

I then run the following commands to attempt to setup all the required tokens etc… (if the server has an external IP, and I want it use the internal ip:

curl -s "http://$IP:$PORT/v2-beta/settings/" -X PUT -H 'content-type: application/json' --data @configapi_updated.json

Then ask to create the registration token:
curl -s -X POST "http://$IP:$PORT/v1/registrationtokens?projectId=1a5"

Then I can get the details:

curl -s -X GET "http://$IP:$PORT/v1/registrationtokens?projectId=1a5" | jq -r '.data[0].command'

to put into the cloud-init of the agent.

If I then startup the agent I get the following errors in the log of the server.

2017-10-31 09:44:33,046 ERROR [:] [] [] [] [TaskScheduler-1] [ ] Failed to get ping from agent [1] count [3]
2017-10-31 09:44:38,050 ERROR [:] [] [] [] [TaskScheduler-1] [ ] Failed to get ping from agent [1] count [4]
2017-10-31 09:44:43,052 ERROR [:] [] [] [] [TaskScheduler-1] [ ] Failed to get ping from agent [1] count [5]
2017-10-31 09:44:48,053 ERROR [:] [] [] [] [TaskScheduler-1] [ ] Failed to get ping from agent [1] count [6]

However, if I manually (via the UI) click the add host button (and not run the above curl commands)… Then use that link and put it in the cloud init… it all works??

What steps am i missing that the UI does behind the scenes, that I need to do programmatically?


The UI doesn’t do anything of significance different, it just creates one if none exists already. (I don’t think it matters, but it uses /v2-beta/projects/1a5/registrationTokens instead of query param)

If you run those one right after another the registrationToken is still going to be transitioning and the command will be null… But then you wouldn’t have registered the host so the server log wouldn’t be saying anything…

Thanks, I will have a play today…
I think, the issue is (while testing) i have public IP on the server, and an the internal address… The Agent is starting up and connecting to the server, but the server is then attempting to connect to 192.168.20.* (for instance) and routing incorrectly out onto the interwebs to attempt to connect.

After checking, if I use the public IP as the call back, it all seems to work.

Turned out to be the MTU was not low enough in Openstack…

ip link set dev eth0 mtu 1400

in cloud init fixed it (on the server only)