# Automating Server/Agent deployment

**URL:** https://forums.suse.com/t/automating-server-agent-deployment/7692
**Category:** General
**Created:** [October 31, 2017, 9:48am UTC](https://forums.suse.com/t/automating-server-agent-deployment/7692 "2017-10-31T09:48:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![joe90](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joe90/32/2990_2.png) [@joe90](https://forums.suse.com/u/joe90)
#### Post date: [October 31, 2017, 9:48am UTC](https://forums.suse.com/t/automating-server-agent-deployment/7692/1 "2017-10-31T09:48:02Z")

</div>

Hi,

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/api.host" -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] [i.c.p.a.s.ping.impl.PingMonitorImpl] Failed to get ping from agent [1] count [3]
2017-10-31 09:44:38,050 ERROR [:] [] [] [] [TaskScheduler-1] [i.c.p.a.s.ping.impl.PingMonitorImpl] Failed to get ping from agent [1] count [4]
2017-10-31 09:44:43,052 ERROR [:] [] [] [] [TaskScheduler-1] [i.c.p.a.s.ping.impl.PingMonitorImpl] Failed to get ping from agent [1] count [5]
2017-10-31 09:44:48,053 ERROR [:] [] [] [] [TaskScheduler-1] [i.c.p.a.s.ping.impl.PingMonitorImpl] 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?

Thanks

---

<div class="post-metadata">

### Author: ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)
#### Post date: [October 31, 2017, 6:52pm UTC](https://forums.suse.com/t/automating-server-agent-deployment/7692/2 "2017-10-31T18:52:00Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![joe90](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joe90/32/2990_2.png) [@joe90](https://forums.suse.com/u/joe90)
#### Post date: [November 1, 2017, 9:16am UTC](https://forums.suse.com/t/automating-server-agent-deployment/7692/3 "2017-11-01T09:16:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![joe90](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joe90/32/2990_2.png) [@joe90](https://forums.suse.com/u/joe90)
#### Post date: [November 2, 2017, 3:59pm UTC](https://forums.suse.com/t/automating-server-agent-deployment/7692/4 "2017-11-02T15:59:43Z")

</div>

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)
