# Cloud-config auto join rancher and hostname

**URL:** <https://forums.suse.com/t/cloud-config-auto-join-rancher-and-hostname/7869>\
**Category:** RancherOS\
**Created:** [November 22, 2017, 9:56pm UTC](https://forums.suse.com/t/cloud-config-auto-join-rancher-and-hostname/7869 "2017-11-22T21:56:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gggggggg](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@gggggggg](https://forums.suse.com/u/gggggggg)\
**Post date:** [November 22, 2017, 9:56pm UTC](https://forums.suse.com/t/cloud-config-auto-join-rancher-and-hostname/7869/1 "2017-11-22T21:56:39Z")

</div>

I am getting there with setting up my rancher envt. I have a cloud-config.yml with all the items I want in it for my hosts.

Two questions though please.

1. If i dont add a hostname, every host has the same same. Is that a issue?

2. Can I add this line to my cloud-cofig file (somehow), so I dont have to do it manually?  
`sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.6 http://rancher:8080/v1/scripts/FA643536EDF:148334545000:t3K454mVE`  
Or would I run into issue with version changes etc.

thanks

---

<div class="post-metadata">

**Author:** ![CWRau](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/cwrau/32/4026_2.png) [@CWRau](https://forums.suse.com/u/CWRau)\
**Post date:** [May 25, 2018, 3:54pm UTC](https://forums.suse.com/t/cloud-config-auto-join-rancher-and-hostname/7869/2 "2018-05-25T15:54:05Z")

</div>

I’m trying to accomplish the same goal, but I can’t figure out how. Did you ever managed to get it working?

My (non-working) cloud config is:

> #cloud-config  
> write\_files:  
> - path: /etc/rc.local  
> permissions: “0755”  
> owner: root  
> content: |  
> #!/bin/bash  
> wait-for-docker  
> docker run -d --privileged --restart=unless-stopped --net=host -v / etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.0. 2 --server https://\_rancher\_host --token _token_ --ca-checksum _checksum_ --etcd --controlplane --worker
