# Cloud-init install on disk

**URL:** <https://forums.suse.com/t/cloud-init-install-on-disk/16116>\
**Category:** RancherOS\
**Created:** [December 19, 2019, 10:34am UTC](https://forums.suse.com/t/cloud-init-install-on-disk/16116 "2019-12-19T10:34:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aracannan](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Aracannan](https://forums.suse.com/u/Aracannan)\
**Post date:** [December 19, 2019, 10:34am UTC](https://forums.suse.com/t/cloud-init-install-on-disk/16116/1 "2019-12-19T10:34:58Z")

</div>

Hi,

I’m looking to automatically deploy RancherOS vms on Vsphere.  
These vm are then used to deploy a RKE K8S cluster.

With `govc` I add the cloud-config.yml for the cloud-init:

```auto
# | cloud-init.config.data | string |
govc vm.change -vm $vm -e 'guestinfo.cloud-init.config.data'=$(base64 -w0 cloud-config_master-test-1.yml)
# | cloud-init.data.encoding | {“”, “base64”, “gzip+base64”} |
govc vm.change -vm $vm -e 'guestinfo.cloud-init.data.encoding'='base64'

```

My cloud-config **cloud-config\_master-test-1.yml** file :

```auto
#cloud-config
hostname: master-test-1
rancher:
  cloud_init:
    datasources:
    - configdrive:/media/config-2
    - vmware
  environment:
    EXTRA_CMDLINE: /init
  network:
    dns:
      nameservers:
      - XXXX
      search:
      - XXXX
    interfaces:
      eth0:
        addresses:
        - XXXX
        gateway: XXXX
        match: eth0
      eth1:
        addresses:
        - XXXX
        gateway: XXXX
        match: eth1
  services_include:
    open-vm-tools: true
ssh_authorized_keys: 
  - ssh-rsa XXXX

```

And I boot on the ISO RancherOS.  
The OS boot well with the configuration given in the cloud-init loaded in memory.

**My question: To make the configuration persistent, I am required to do a “ros install” or is there a way to say in the cloud-init to do the installation on the disk ?**

Thanks,  
Aracannan

---

<div class="post-metadata">

**Author:** ![topuli](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@topuli](https://forums.suse.com/u/topuli)\
**Post date:** [December 30, 2019, 8:21am UTC](https://forums.suse.com/t/cloud-init-install-on-disk/16116/2 "2019-12-30T08:21:04Z")

</div>

Hi Aracannan,

adding the following lines to the cloud-config file worked for me:

write\_files:  
permissions: “0755”  
owner: root  
content: |  
#!/bin/bash  
if [-e /home/rancher/touched\_by\_local]  
then  
echo “” \> /etc/rc.local  
else  
echo “rc local checkfile” \> /home/rancher/touched\_by\_local  
wget -O /home/rancher/cloud-config.yml [http://YOURSERVER.YOUR-SERVERDOMAIN/cloud-config.yml](http://YOURSERVER.YOUR-SERVERDOMAIN/cloud-config.yml)  
sudo ros install -f -c /home/rancher/cloud-config.yml -d /dev/sda  
fi

t.

---

<div class="post-metadata">

**Author:** ![LarsAC](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/larsac/32/6423_2.png) [@LarsAC](https://forums.suse.com/u/LarsAC)\
**Post date:** [January 20, 2020, 7:28pm UTC](https://forums.suse.com/t/cloud-init-install-on-disk/16116/3 "2020-01-20T19:28:47Z")

</div>

Hi @topuli,

thanks for sharing the snippet. You are not specifying a path for he code under write files - does that work without ? Why would the code get executed ?

I am new and would be glad to understand.

Regards,  
Lars

---

<div class="post-metadata">

**Author:** ![topuli](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@topuli](https://forums.suse.com/u/topuli)\
**Post date:** [January 21, 2020, 11:55am UTC](https://forums.suse.com/t/cloud-init-install-on-disk/16116/4 "2020-01-21T11:55:14Z")

</div>

you are right, i missed a line when i copy/pasted it:

write\_files:

- path: /etc/rc.local  
permissions: “0755”  
owner: root  
content: |  
#!/bin/bash  
if [-e /home/rancher/touched\_by\_local\_iso]  
then  
echo “” \> /etc/rc.local  
else  
echo “rc local iso checkfile” \> /home/rancher/touched\_by\_local\_iso  
wget -O /home/rancher/cloud-config.yml [http://vmdev172.adv.magwien.gv.at:88/ros/cloud-config/hru\_cloud-config.yml](http://vmdev172.adv.magwien.gv.at:88/ros/cloud-config/hru_cloud-config.yml)  
sudo ros install -f -c /home/rancher/cloud-config.yml -d /dev/sda  
fi

t.
